diff options
author | John Hurliman | 2010-02-22 14:10:19 -0800 |
---|---|---|
committer | John Hurliman | 2010-02-22 14:10:19 -0800 |
commit | 71c6559a91a58d93588dcdd8c74b5fce0c1a3780 (patch) | |
tree | cca5b1ea88ad4b29156767afdd77e37ec072c8a7 | |
parent | * Adds CreatorID to asset metadata. This is just the plumbing to support Crea... (diff) | |
parent | Merge branch 'presence-refactor' of ssh://diva@opensimulator.org/var/git/open... (diff) | |
download | opensim-SC_OLD-71c6559a91a58d93588dcdd8c74b5fce0c1a3780.zip opensim-SC_OLD-71c6559a91a58d93588dcdd8c74b5fce0c1a3780.tar.gz opensim-SC_OLD-71c6559a91a58d93588dcdd8c74b5fce0c1a3780.tar.bz2 opensim-SC_OLD-71c6559a91a58d93588dcdd8c74b5fce0c1a3780.tar.xz |
Merge branch 'presence-refactor' of ssh://opensimulator.org/var/git/opensim into presence-refactor
94 files changed, 1068 insertions, 14387 deletions
diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt index 13c05ef..5b4959a 100644 --- a/CONTRIBUTORS.txt +++ b/CONTRIBUTORS.txt | |||
@@ -128,6 +128,7 @@ what it is today. | |||
128 | * YZh | 128 | * YZh |
129 | * Zackary Geers aka Kunnis Basiat | 129 | * Zackary Geers aka Kunnis Basiat |
130 | * Zha Ewry | 130 | * Zha Ewry |
131 | * ziah | ||
131 | 132 | ||
132 | 133 | ||
133 | = LSL Devs = | 134 | = LSL Devs = |
diff --git a/OpenSim/Data/DataPluginFactory.cs b/OpenSim/Data/DataPluginFactory.cs deleted file mode 100644 index 841f71e..0000000 --- a/OpenSim/Data/DataPluginFactory.cs +++ /dev/null | |||
@@ -1,155 +0,0 @@ | |||
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 OpenSim.Framework; | ||
31 | |||
32 | namespace OpenSim.Data | ||
33 | { | ||
34 | /// <summary> | ||
35 | /// A static class containing methods for obtaining handles to database | ||
36 | /// storage objects. | ||
37 | /// </summary> | ||
38 | public static class DataPluginFactory | ||
39 | { | ||
40 | /// <summary> | ||
41 | /// Based on <typeparam name="T" />, returns the appropriate | ||
42 | /// PluginInitialiserBase instance in <paramref name="init" /> and | ||
43 | /// extension point path in <paramref name="path" />. | ||
44 | /// </summary> | ||
45 | /// <param name="connect"> | ||
46 | /// The DB connection string used when creating a new | ||
47 | /// PluginInitialiserBase, returned in <paramref name="init" />. | ||
48 | /// </param> | ||
49 | /// <param name="init"> | ||
50 | /// A reference to a PluginInitialiserBase object in which the proper | ||
51 | /// initialiser will be returned. | ||
52 | /// </param> | ||
53 | /// <param name="path"> | ||
54 | /// A string in which the proper extension point path will be returned. | ||
55 | /// </param> | ||
56 | /// <typeparam name="T"> | ||
57 | /// The type of data plugin requested. | ||
58 | /// </typeparam> | ||
59 | /// <exception cref="NotImplementedException"> | ||
60 | /// Thrown if <typeparamref name="T" /> is not one of the expected data | ||
61 | /// interfaces. | ||
62 | /// </exception> | ||
63 | private static void PluginLoaderParamFactory<T>(string connect, out PluginInitialiserBase init, out string path) where T : IPlugin | ||
64 | { | ||
65 | Type type = typeof(T); | ||
66 | |||
67 | if (type == typeof(IInventoryDataPlugin)) | ||
68 | { | ||
69 | init = new InventoryDataInitialiser(connect); | ||
70 | path = "/OpenSim/InventoryData"; | ||
71 | } | ||
72 | else if (type == typeof(IUserDataPlugin)) | ||
73 | { | ||
74 | init = new UserDataInitialiser(connect); | ||
75 | path = "/OpenSim/UserData"; | ||
76 | } | ||
77 | else if (type == typeof(IGridDataPlugin)) | ||
78 | { | ||
79 | init = new GridDataInitialiser(connect); | ||
80 | path = "/OpenSim/GridData"; | ||
81 | } | ||
82 | else if (type == typeof(ILogDataPlugin)) | ||
83 | { | ||
84 | init = new LogDataInitialiser(connect); | ||
85 | path = "/OpenSim/LogData"; | ||
86 | } | ||
87 | else if (type == typeof(IAssetDataPlugin)) | ||
88 | { | ||
89 | init = new AssetDataInitialiser(connect); | ||
90 | path = "/OpenSim/AssetData"; | ||
91 | } | ||
92 | else | ||
93 | { | ||
94 | // We don't support this data plugin. | ||
95 | throw new NotImplementedException(String.Format("The type '{0}' is not a valid data plugin.", type)); | ||
96 | } | ||
97 | } | ||
98 | |||
99 | /// <summary> | ||
100 | /// Returns a list of new <typeparamref name="T" /> data plugins. | ||
101 | /// Plugins will be requested in the order they were added. | ||
102 | /// </summary> | ||
103 | /// <param name="provider"> | ||
104 | /// The filename of the inventory server plugin DLL. | ||
105 | /// </param> | ||
106 | /// <param name="connect"> | ||
107 | /// The connection string for the storage backend. | ||
108 | /// </param> | ||
109 | /// <typeparam name="T"> | ||
110 | /// The type of data plugin requested. | ||
111 | /// </typeparam> | ||
112 | /// <returns> | ||
113 | /// A list of all loaded plugins matching <typeparamref name="T" />. | ||
114 | /// </returns> | ||
115 | public static List<T> LoadDataPlugins<T>(string provider, string connect) where T : IPlugin | ||
116 | { | ||
117 | PluginInitialiserBase pluginInitialiser; | ||
118 | string extensionPointPath; | ||
119 | |||
120 | PluginLoaderParamFactory<T>(connect, out pluginInitialiser, out extensionPointPath); | ||
121 | |||
122 | using (PluginLoader<T> loader = new PluginLoader<T>(pluginInitialiser)) | ||
123 | { | ||
124 | // loader will try to load all providers (MySQL, MSSQL, etc) | ||
125 | // unless it is constrainted to the correct "Provider" entry in the addin.xml | ||
126 | loader.Add(extensionPointPath, new PluginProviderFilter(provider)); | ||
127 | loader.Load(); | ||
128 | |||
129 | return loader.Plugins; | ||
130 | } | ||
131 | } | ||
132 | |||
133 | /// <summary> | ||
134 | /// Returns a new <typeparamref name="T" /> data plugin instance if | ||
135 | /// only one was loaded, otherwise returns null (<c>default(T)</c>). | ||
136 | /// </summary> | ||
137 | /// <param name="provider"> | ||
138 | /// The filename of the inventory server plugin DLL. | ||
139 | /// </param> | ||
140 | /// <param name="connect"> | ||
141 | /// The connection string for the storage backend. | ||
142 | /// </param> | ||
143 | /// <typeparam name="T"> | ||
144 | /// The type of data plugin requested. | ||
145 | /// </typeparam> | ||
146 | /// <returns> | ||
147 | /// A list of all loaded plugins matching <typeparamref name="T" />. | ||
148 | /// </returns> | ||
149 | public static T LoadDataPlugin<T>(string provider, string connect) where T : IPlugin | ||
150 | { | ||
151 | List<T> plugins = LoadDataPlugins<T>(provider, connect); | ||
152 | return (plugins.Count == 1) ? plugins[0] : default(T); | ||
153 | } | ||
154 | } | ||
155 | } | ||
diff --git a/OpenSim/Data/GridDataBase.cs b/OpenSim/Data/GridDataBase.cs deleted file mode 100644 index a03488b..0000000 --- a/OpenSim/Data/GridDataBase.cs +++ /dev/null | |||
@@ -1,52 +0,0 @@ | |||
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.Generic; | ||
29 | using OpenMetaverse; | ||
30 | |||
31 | namespace OpenSim.Data | ||
32 | { | ||
33 | public abstract class GridDataBase : IGridDataPlugin | ||
34 | { | ||
35 | public abstract RegionProfileData GetProfileByHandle(ulong regionHandle); | ||
36 | public abstract RegionProfileData GetProfileByUUID(UUID UUID); | ||
37 | public abstract RegionProfileData GetProfileByString(string regionName); | ||
38 | public abstract RegionProfileData[] GetProfilesInRange(uint Xmin, uint Ymin, uint Xmax, uint Ymax); | ||
39 | public abstract List<RegionProfileData> GetRegionsByName(string namePrefix, uint maxNum); | ||
40 | public abstract bool AuthenticateSim(UUID UUID, ulong regionHandle, string simrecvkey); | ||
41 | public abstract DataResponse StoreProfile(RegionProfileData profile); | ||
42 | public abstract ReservationData GetReservationAtPoint(uint x, uint y); | ||
43 | public abstract DataResponse DeleteProfile(string uuid); | ||
44 | |||
45 | public abstract void Initialise(); | ||
46 | public abstract void Initialise(string connect); | ||
47 | public abstract void Dispose(); | ||
48 | |||
49 | public abstract string Name { get; } | ||
50 | public abstract string Version { get; } | ||
51 | } | ||
52 | } | ||
diff --git a/OpenSim/Data/IGridData.cs b/OpenSim/Data/IGridData.cs deleted file mode 100644 index 8bd3811..0000000 --- a/OpenSim/Data/IGridData.cs +++ /dev/null | |||
@@ -1,134 +0,0 @@ | |||
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.Generic; | ||
29 | using OpenMetaverse; | ||
30 | using OpenSim.Framework; | ||
31 | |||
32 | namespace OpenSim.Data | ||
33 | { | ||
34 | public enum DataResponse | ||
35 | { | ||
36 | RESPONSE_OK, | ||
37 | RESPONSE_AUTHREQUIRED, | ||
38 | RESPONSE_INVALIDCREDENTIALS, | ||
39 | RESPONSE_ERROR | ||
40 | } | ||
41 | |||
42 | /// <summary> | ||
43 | /// A standard grid interface | ||
44 | /// </summary> | ||
45 | public interface IGridDataPlugin : IPlugin | ||
46 | { | ||
47 | /// <summary> | ||
48 | /// Initialises the interface | ||
49 | /// </summary> | ||
50 | void Initialise(string connect); | ||
51 | |||
52 | /// <summary> | ||
53 | /// Returns a sim profile from a regionHandle | ||
54 | /// </summary> | ||
55 | /// <param name="regionHandle">A 64bit Region Handle</param> | ||
56 | /// <returns>A simprofile</returns> | ||
57 | RegionProfileData GetProfileByHandle(ulong regionHandle); | ||
58 | |||
59 | /// <summary> | ||
60 | /// Returns a sim profile from a UUID | ||
61 | /// </summary> | ||
62 | /// <param name="UUID">A 128bit UUID</param> | ||
63 | /// <returns>A sim profile</returns> | ||
64 | RegionProfileData GetProfileByUUID(UUID UUID); | ||
65 | |||
66 | /// <summary> | ||
67 | /// Returns a sim profile from a string match | ||
68 | /// </summary> | ||
69 | /// <param name="regionName">A string for a partial region name match</param> | ||
70 | /// <returns>A sim profile</returns> | ||
71 | RegionProfileData GetProfileByString(string regionName); | ||
72 | |||
73 | /// <summary> | ||
74 | /// Returns all profiles within the specified range | ||
75 | /// </summary> | ||
76 | /// <param name="Xmin">Minimum sim coordinate (X)</param> | ||
77 | /// <param name="Ymin">Minimum sim coordinate (Y)</param> | ||
78 | /// <param name="Xmax">Maximum sim coordinate (X)</param> | ||
79 | /// <param name="Ymin">Maximum sim coordinate (Y)</param> | ||
80 | /// <returns>An array containing all the sim profiles in the specified range</returns> | ||
81 | RegionProfileData[] GetProfilesInRange(uint Xmin, uint Ymin, uint Xmax, uint Ymax); | ||
82 | |||
83 | /// <summary> | ||
84 | /// Returns up to maxNum profiles of regions that have a name starting with namePrefix | ||
85 | /// </summary> | ||
86 | /// <param name="name">The name to match against</param> | ||
87 | /// <param name="maxNum">Maximum number of profiles to return</param> | ||
88 | /// <returns>A list of sim profiles</returns> | ||
89 | List<RegionProfileData> GetRegionsByName(string namePrefix, uint maxNum); | ||
90 | |||
91 | /// <summary> | ||
92 | /// Authenticates a sim by use of its recv key. | ||
93 | /// WARNING: Insecure | ||
94 | /// </summary> | ||
95 | /// <param name="UUID">The UUID sent by the sim</param> | ||
96 | /// <param name="regionHandle">The regionhandle sent by the sim</param> | ||
97 | /// <param name="simrecvkey">The receiving key sent by the sim</param> | ||
98 | /// <returns>Whether the sim has been authenticated</returns> | ||
99 | bool AuthenticateSim(UUID UUID, ulong regionHandle, string simrecvkey); | ||
100 | |||
101 | /// <summary> | ||
102 | /// Adds or updates a profile in the database | ||
103 | /// </summary> | ||
104 | /// <param name="profile">The profile to add</param> | ||
105 | /// <returns>RESPONSE_OK if successful, error if not.</returns> | ||
106 | DataResponse StoreProfile(RegionProfileData profile); | ||
107 | |||
108 | /// <summary> | ||
109 | /// Remove a profile from the database | ||
110 | /// </summary> | ||
111 | /// <param name="UUID">ID of profile to remove</param> | ||
112 | /// <returns></returns> | ||
113 | DataResponse DeleteProfile(string UUID); | ||
114 | |||
115 | /// <summary> | ||
116 | /// Function not used???? | ||
117 | /// </summary> | ||
118 | /// <param name="x"></param> | ||
119 | /// <param name="y"></param> | ||
120 | /// <returns></returns> | ||
121 | ReservationData GetReservationAtPoint(uint x, uint y); | ||
122 | } | ||
123 | |||
124 | public class GridDataInitialiser : PluginInitialiserBase | ||
125 | { | ||
126 | private string connect; | ||
127 | public GridDataInitialiser (string s) { connect = s; } | ||
128 | public override void Initialise (IPlugin plugin) | ||
129 | { | ||
130 | IGridDataPlugin p = plugin as IGridDataPlugin; | ||
131 | p.Initialise (connect); | ||
132 | } | ||
133 | } | ||
134 | } | ||
diff --git a/OpenSim/Data/ILogData.cs b/OpenSim/Data/ILogData.cs deleted file mode 100644 index 97ca1cc..0000000 --- a/OpenSim/Data/ILogData.cs +++ /dev/null | |||
@@ -1,87 +0,0 @@ | |||
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 OpenSim.Framework; | ||
29 | |||
30 | namespace OpenSim.Data | ||
31 | { | ||
32 | /// <summary> | ||
33 | /// The severity of an individual log message | ||
34 | /// </summary> | ||
35 | public enum LogSeverity : int | ||
36 | { | ||
37 | /// <summary> | ||
38 | /// Critical: systems failure | ||
39 | /// </summary> | ||
40 | CRITICAL = 1, | ||
41 | /// <summary> | ||
42 | /// Major: warning prior to systems failure | ||
43 | /// </summary> | ||
44 | MAJOR = 2, | ||
45 | /// <summary> | ||
46 | /// Medium: an individual non-critical task failed | ||
47 | /// </summary> | ||
48 | MEDIUM = 3, | ||
49 | /// <summary> | ||
50 | /// Low: Informational warning | ||
51 | /// </summary> | ||
52 | LOW = 4, | ||
53 | /// <summary> | ||
54 | /// Info: Information | ||
55 | /// </summary> | ||
56 | INFO = 5, | ||
57 | /// <summary> | ||
58 | /// Verbose: Debug Information | ||
59 | /// </summary> | ||
60 | VERBOSE = 6 | ||
61 | } | ||
62 | |||
63 | /// <summary> | ||
64 | /// An interface to a LogData storage system | ||
65 | /// </summary> | ||
66 | public interface ILogDataPlugin : IPlugin | ||
67 | { | ||
68 | void saveLog(string serverDaemon, string target, string methodCall, string arguments, int priority, | ||
69 | string logMessage); | ||
70 | |||
71 | /// <summary> | ||
72 | /// Initialises the interface | ||
73 | /// </summary> | ||
74 | void Initialise(string connect); | ||
75 | } | ||
76 | |||
77 | public class LogDataInitialiser : PluginInitialiserBase | ||
78 | { | ||
79 | private string connect; | ||
80 | public LogDataInitialiser (string s) { connect = s; } | ||
81 | public override void Initialise (IPlugin plugin) | ||
82 | { | ||
83 | ILogDataPlugin p = plugin as ILogDataPlugin; | ||
84 | p.Initialise (connect); | ||
85 | } | ||
86 | } | ||
87 | } | ||
diff --git a/OpenSim/Data/IRegionProfileService.cs b/OpenSim/Data/IRegionProfileService.cs deleted file mode 100644 index b3acc52..0000000 --- a/OpenSim/Data/IRegionProfileService.cs +++ /dev/null | |||
@@ -1,100 +0,0 @@ | |||
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.Text; | ||
31 | using OpenMetaverse; | ||
32 | |||
33 | namespace OpenSim.Data | ||
34 | { | ||
35 | public interface IRegionProfileService | ||
36 | { | ||
37 | /// <summary> | ||
38 | /// Returns a region by argument | ||
39 | /// </summary> | ||
40 | /// <param name="uuid">A UUID key of the region to return</param> | ||
41 | /// <returns>A SimProfileData for the region</returns> | ||
42 | RegionProfileData GetRegion(UUID uuid); | ||
43 | |||
44 | /// <summary> | ||
45 | /// Returns a region by argument | ||
46 | /// </summary> | ||
47 | /// <param name="uuid">A regionHandle of the region to return</param> | ||
48 | /// <returns>A SimProfileData for the region</returns> | ||
49 | RegionProfileData GetRegion(ulong handle); | ||
50 | |||
51 | /// <summary> | ||
52 | /// Returns a region by argument | ||
53 | /// </summary> | ||
54 | /// <param name="regionName">A partial regionName of the region to return</param> | ||
55 | /// <returns>A SimProfileData for the region</returns> | ||
56 | RegionProfileData GetRegion(string regionName); | ||
57 | |||
58 | List<RegionProfileData> GetRegions(uint xmin, uint ymin, uint xmax, uint ymax); | ||
59 | List<RegionProfileData> GetRegions(string name, int maxNum); | ||
60 | DataResponse AddUpdateRegion(RegionProfileData sim, RegionProfileData existingSim); | ||
61 | DataResponse DeleteRegion(string uuid); | ||
62 | } | ||
63 | |||
64 | public interface IRegionProfileRouter | ||
65 | { | ||
66 | /// <summary> | ||
67 | /// Request sim profile information from a grid server, by Region UUID | ||
68 | /// </summary> | ||
69 | /// <param name="regionId">The region UUID to look for</param> | ||
70 | /// <param name="gridserverUrl"></param> | ||
71 | /// <param name="gridserverSendkey"></param> | ||
72 | /// <param name="gridserverRecvkey"></param> | ||
73 | /// <returns>The sim profile. Null if there was a request failure</returns> | ||
74 | /// <remarks>This method should be statics</remarks> | ||
75 | RegionProfileData RequestSimProfileData(UUID regionId, Uri gridserverUrl, | ||
76 | string gridserverSendkey, string gridserverRecvkey); | ||
77 | |||
78 | /// <summary> | ||
79 | /// Request sim profile information from a grid server, by Region Handle | ||
80 | /// </summary> | ||
81 | /// <param name="regionHandle">the region handle to look for</param> | ||
82 | /// <param name="gridserverUrl"></param> | ||
83 | /// <param name="gridserverSendkey"></param> | ||
84 | /// <param name="gridserverRecvkey"></param> | ||
85 | /// <returns>The sim profile. Null if there was a request failure</returns> | ||
86 | RegionProfileData RequestSimProfileData(ulong regionHandle, Uri gridserverUrl, | ||
87 | string gridserverSendkey, string gridserverRecvkey); | ||
88 | |||
89 | /// <summary> | ||
90 | /// Request sim profile information from a grid server, by Region Name | ||
91 | /// </summary> | ||
92 | /// <param name="regionName">the region name to look for</param> | ||
93 | /// <param name="gridserverUrl"></param> | ||
94 | /// <param name="gridserverSendkey"></param> | ||
95 | /// <param name="gridserverRecvkey"></param> | ||
96 | /// <returns>The sim profile. Null if there was a request failure</returns> | ||
97 | RegionProfileData RequestSimProfileData(string regionName, Uri gridserverUrl, | ||
98 | string gridserverSendkey, string gridserverRecvkey); | ||
99 | } | ||
100 | } | ||
diff --git a/OpenSim/Data/IUserData.cs b/OpenSim/Data/IUserData.cs deleted file mode 100644 index e9a1e81..0000000 --- a/OpenSim/Data/IUserData.cs +++ /dev/null | |||
@@ -1,209 +0,0 @@ | |||
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 OpenMetaverse; | ||
31 | using OpenSim.Framework; | ||
32 | |||
33 | namespace OpenSim.Data | ||
34 | { | ||
35 | /// <summary> | ||
36 | /// An interface for connecting to user storage servers. | ||
37 | /// </summary> | ||
38 | public interface IUserDataPlugin : IPlugin | ||
39 | { | ||
40 | /// <summary> | ||
41 | /// Returns a user profile from a database via their UUID | ||
42 | /// </summary> | ||
43 | /// <param name="user">The user's UUID</param> | ||
44 | /// <returns>The user data profile. Returns null if no user is found</returns> | ||
45 | UserProfileData GetUserByUUID(UUID user); | ||
46 | |||
47 | /// <summary> | ||
48 | /// Returns a users profile by searching their username parts | ||
49 | /// </summary> | ||
50 | /// <param name="fname">Account firstname</param> | ||
51 | /// <param name="lname">Account lastname</param> | ||
52 | /// <returns>The user data profile. Null if no user is found</returns> | ||
53 | UserProfileData GetUserByName(string fname, string lname); | ||
54 | |||
55 | /// <summary> | ||
56 | /// Get a user from a given uri. | ||
57 | /// </summary> | ||
58 | /// <param name="uri"></param> | ||
59 | /// <returns>The user data profile. Null if no user is found.</returns> | ||
60 | UserProfileData GetUserByUri(Uri uri); | ||
61 | |||
62 | /// <summary> | ||
63 | /// Returns a list of UUIDs firstnames and lastnames that match string query entered into the avatar picker. | ||
64 | /// </summary> | ||
65 | /// <param name="queryID">ID associated with the user's query. This must match what the client sent</param> | ||
66 | /// <param name="query">The filtered contents of the search box when the user hit search.</param> | ||
67 | /// <returns>A list of user details. If there are no results than either an empty list or null</returns> | ||
68 | List<AvatarPickerAvatar> GeneratePickerResults(UUID queryID, string query); | ||
69 | |||
70 | /// <summary> | ||
71 | /// Returns the current agent for a user searching by it's UUID | ||
72 | /// </summary> | ||
73 | /// <param name="user">The users UUID</param> | ||
74 | /// <returns>The current agent session. Null if no session was found</returns> | ||
75 | UserAgentData GetAgentByUUID(UUID user); | ||
76 | |||
77 | /// <summary> | ||
78 | /// Returns the current session agent for a user searching by username | ||
79 | /// </summary> | ||
80 | /// <param name="name">The users account name</param> | ||
81 | /// <returns>The current agent session</returns> | ||
82 | UserAgentData GetAgentByName(string name); | ||
83 | |||
84 | /// <summary> | ||
85 | /// Returns the current session agent for a user searching by username parts | ||
86 | /// </summary> | ||
87 | /// <param name="fname">The users first account name</param> | ||
88 | /// <param name="lname">The users account surname</param> | ||
89 | /// <returns>The current agent session</returns> | ||
90 | UserAgentData GetAgentByName(string fname, string lname); | ||
91 | |||
92 | /// <summary> | ||
93 | /// Stores new web-login key for user during web page login | ||
94 | /// </summary> | ||
95 | /// <param name="webLoginKey"></param> | ||
96 | void StoreWebLoginKey(UUID agentID, UUID webLoginKey); | ||
97 | |||
98 | /// <summary> | ||
99 | /// Adds a new User profile to the database | ||
100 | /// </summary> | ||
101 | /// <param name="user">UserProfile to add</param> | ||
102 | void AddNewUserProfile(UserProfileData user); | ||
103 | |||
104 | /// <summary> | ||
105 | /// Adds a temporary user profile. A temporary userprofile is one that should exist only for the lifetime of | ||
106 | /// the process. | ||
107 | /// </summary> | ||
108 | /// <param name="userProfile"></param> | ||
109 | void AddTemporaryUserProfile(UserProfileData userProfile); | ||
110 | |||
111 | /// <summary> | ||
112 | /// Updates an existing user profile | ||
113 | /// </summary> | ||
114 | /// <param name="user">UserProfile to update</param> | ||
115 | bool UpdateUserProfile(UserProfileData user); | ||
116 | |||
117 | /// <summary> | ||
118 | /// Adds a new agent to the database | ||
119 | /// </summary> | ||
120 | /// <param name="agent">The agent to add</param> | ||
121 | void AddNewUserAgent(UserAgentData agent); | ||
122 | |||
123 | /// <summary> | ||
124 | /// Adds a new friend to the database for XUser | ||
125 | /// </summary> | ||
126 | /// <param name="friendlistowner">The agent that who's friends list is being added to</param> | ||
127 | /// <param name="friend">The agent that being added to the friends list of the friends list owner</param> | ||
128 | /// <param name="perms">A uint bit vector for set perms that the friend being added has; 0 = none, 1=This friend can see when they sign on, 2 = map, 4 edit objects </param> | ||
129 | void AddNewUserFriend(UUID friendlistowner, UUID friend, uint perms); | ||
130 | |||
131 | /// <summary> | ||
132 | /// Delete friend on friendlistowner's friendlist. | ||
133 | /// </summary> | ||
134 | /// <param name="friendlistowner">The agent that who's friends list is being updated</param> | ||
135 | /// <param name="friend">The Ex-friend agent</param> | ||
136 | void RemoveUserFriend(UUID friendlistowner, UUID friend); | ||
137 | |||
138 | /// <summary> | ||
139 | /// Update permissions for friend on friendlistowner's friendlist. | ||
140 | /// </summary> | ||
141 | /// <param name="friendlistowner">The agent that who's friends list is being updated</param> | ||
142 | /// <param name="friend">The agent that is getting or loosing permissions</param> | ||
143 | /// <param name="perms">A uint bit vector for set perms that the friend being added has; 0 = none, 1=This friend can see when they sign on, 2 = map, 4 edit objects </param> | ||
144 | void UpdateUserFriendPerms(UUID friendlistowner, UUID friend, uint perms); | ||
145 | |||
146 | /// <summary> | ||
147 | /// Returns a list of FriendsListItems that describe the friends and permissions in the friend relationship for UUID friendslistowner | ||
148 | /// </summary> | ||
149 | /// <param name="friendlistowner">The agent that we're retreiving the friends Data.</param> | ||
150 | /// <returns>The user's friends. If there are no results than either an empty list or null</returns> | ||
151 | List<FriendListItem> GetUserFriendList(UUID friendlistowner); | ||
152 | |||
153 | /// <summary> | ||
154 | /// Returns a list of <see cref="FriendRegionInfo/>s for the specified UUIDs. | ||
155 | /// </summary> | ||
156 | /// <param name="uuids"> | ||
157 | /// A <see cref="List"/> of <see cref="UUID/>s to fetch info for | ||
158 | /// </param> | ||
159 | /// <returns> | ||
160 | /// A <see cref="Dictionary"/>, mapping the <see cref="UUID"/>s to <see cref="FriendRegionInfo"/>s. | ||
161 | /// </returns> | ||
162 | Dictionary<UUID, FriendRegionInfo> GetFriendRegionInfos(List<UUID> uuids); | ||
163 | |||
164 | /// <summary> | ||
165 | /// Attempts to move currency units between accounts (NOT RELIABLE / TRUSTWORTHY. DONT TRY RUN YOUR OWN CURRENCY EXCHANGE WITH REAL VALUES) | ||
166 | /// </summary> | ||
167 | /// <param name="from">The account to transfer from</param> | ||
168 | /// <param name="to">The account to transfer to</param> | ||
169 | /// <param name="amount">The amount to transfer</param> | ||
170 | /// <returns>Successful?</returns> | ||
171 | bool MoneyTransferRequest(UUID from, UUID to, uint amount); | ||
172 | |||
173 | /// <summary> | ||
174 | /// Attempts to move inventory between accounts, if inventory is copyable it will be copied into the target account. | ||
175 | /// </summary> | ||
176 | /// <param name="from">User to transfer from</param> | ||
177 | /// <param name="to">User to transfer to</param> | ||
178 | /// <param name="inventory">Specified inventory item</param> | ||
179 | /// <returns>Successful?</returns> | ||
180 | bool InventoryTransferRequest(UUID from, UUID to, UUID inventory); | ||
181 | |||
182 | /// <summary> | ||
183 | /// Initialises the plugin (artificial constructor) | ||
184 | /// </summary> | ||
185 | void Initialise(string connect); | ||
186 | |||
187 | /// <summary> | ||
188 | /// Gets the user appearance | ||
189 | /// </summer> | ||
190 | AvatarAppearance GetUserAppearance(UUID user); | ||
191 | |||
192 | void UpdateUserAppearance(UUID user, AvatarAppearance appearance); | ||
193 | |||
194 | void ResetAttachments(UUID userID); | ||
195 | |||
196 | void LogoutUsers(UUID regionID); | ||
197 | } | ||
198 | |||
199 | public class UserDataInitialiser : PluginInitialiserBase | ||
200 | { | ||
201 | private string connect; | ||
202 | public UserDataInitialiser (string s) { connect = s; } | ||
203 | public override void Initialise (IPlugin plugin) | ||
204 | { | ||
205 | IUserDataPlugin p = plugin as IUserDataPlugin; | ||
206 | p.Initialise (connect); | ||
207 | } | ||
208 | } | ||
209 | } | ||
diff --git a/OpenSim/Data/MSSQL/MSSQLGridData.cs b/OpenSim/Data/MSSQL/MSSQLGridData.cs deleted file mode 100644 index 8a3d332..0000000 --- a/OpenSim/Data/MSSQL/MSSQLGridData.cs +++ /dev/null | |||
@@ -1,587 +0,0 @@ | |||
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.Data; | ||
31 | using System.Data.SqlClient; | ||
32 | using System.Reflection; | ||
33 | using log4net; | ||
34 | using OpenMetaverse; | ||
35 | using OpenSim.Framework; | ||
36 | |||
37 | namespace OpenSim.Data.MSSQL | ||
38 | { | ||
39 | /// <summary> | ||
40 | /// A grid data interface for MSSQL Server | ||
41 | /// </summary> | ||
42 | public class MSSQLGridData : GridDataBase | ||
43 | { | ||
44 | private const string _migrationStore = "GridStore"; | ||
45 | |||
46 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
47 | |||
48 | /// <summary> | ||
49 | /// Database manager | ||
50 | /// </summary> | ||
51 | private MSSQLManager database; | ||
52 | |||
53 | private string m_regionsTableName = "regions"; | ||
54 | |||
55 | #region IPlugin Members | ||
56 | |||
57 | // [Obsolete("Cannot be default-initialized!")] | ||
58 | override public void Initialise() | ||
59 | { | ||
60 | m_log.Info("[GRID DB]: " + Name + " cannot be default-initialized!"); | ||
61 | throw new PluginNotInitialisedException(Name); | ||
62 | } | ||
63 | |||
64 | /// <summary> | ||
65 | /// Initialises the Grid Interface | ||
66 | /// </summary> | ||
67 | /// <param name="connectionString">connect string</param> | ||
68 | /// <remarks>use mssql_connection.ini</remarks> | ||
69 | override public void Initialise(string connectionString) | ||
70 | { | ||
71 | if (!string.IsNullOrEmpty(connectionString)) | ||
72 | { | ||
73 | database = new MSSQLManager(connectionString); | ||
74 | } | ||
75 | else | ||
76 | { | ||
77 | // TODO: make the connect string actually do something | ||
78 | IniFile iniFile = new IniFile("mssql_connection.ini"); | ||
79 | |||
80 | string settingDataSource = iniFile.ParseFileReadValue("data_source"); | ||
81 | string settingInitialCatalog = iniFile.ParseFileReadValue("initial_catalog"); | ||
82 | string settingPersistSecurityInfo = iniFile.ParseFileReadValue("persist_security_info"); | ||
83 | string settingUserId = iniFile.ParseFileReadValue("user_id"); | ||
84 | string settingPassword = iniFile.ParseFileReadValue("password"); | ||
85 | |||
86 | m_regionsTableName = iniFile.ParseFileReadValue("regionstablename"); | ||
87 | if (m_regionsTableName == null) | ||
88 | { | ||
89 | m_regionsTableName = "regions"; | ||
90 | } | ||
91 | |||
92 | database = | ||
93 | new MSSQLManager(settingDataSource, settingInitialCatalog, settingPersistSecurityInfo, settingUserId, | ||
94 | settingPassword); | ||
95 | } | ||
96 | |||
97 | //New migrations check of store | ||
98 | database.CheckMigration(_migrationStore); | ||
99 | } | ||
100 | |||
101 | /// <summary> | ||
102 | /// Shuts down the grid interface | ||
103 | /// </summary> | ||
104 | override public void Dispose() | ||
105 | { | ||
106 | database = null; | ||
107 | } | ||
108 | |||
109 | /// <summary> | ||
110 | /// The name of this DB provider. | ||
111 | /// </summary> | ||
112 | /// <returns>A string containing the storage system name</returns> | ||
113 | override public string Name | ||
114 | { | ||
115 | get { return "MSSQL OpenGridData"; } | ||
116 | } | ||
117 | |||
118 | /// <summary> | ||
119 | /// Database provider version. | ||
120 | /// </summary> | ||
121 | /// <returns>A string containing the storage system version</returns> | ||
122 | override public string Version | ||
123 | { | ||
124 | get { return "0.1"; } | ||
125 | } | ||
126 | |||
127 | #endregion | ||
128 | |||
129 | #region Public override GridDataBase methods | ||
130 | |||
131 | /// <summary> | ||
132 | /// Returns a list of regions within the specified ranges | ||
133 | /// </summary> | ||
134 | /// <param name="xmin">minimum X coordinate</param> | ||
135 | /// <param name="ymin">minimum Y coordinate</param> | ||
136 | /// <param name="xmax">maximum X coordinate</param> | ||
137 | /// <param name="ymax">maximum Y coordinate</param> | ||
138 | /// <returns>null</returns> | ||
139 | /// <remarks>always return null</remarks> | ||
140 | override public RegionProfileData[] GetProfilesInRange(uint xmin, uint ymin, uint xmax, uint ymax) | ||
141 | { | ||
142 | using (AutoClosingSqlCommand command = database.Query("SELECT * FROM regions WHERE locX >= @xmin AND locX <= @xmax AND locY >= @ymin AND locY <= @ymax")) | ||
143 | { | ||
144 | command.Parameters.Add(database.CreateParameter("xmin", xmin)); | ||
145 | command.Parameters.Add(database.CreateParameter("ymin", ymin)); | ||
146 | command.Parameters.Add(database.CreateParameter("xmax", xmax)); | ||
147 | command.Parameters.Add(database.CreateParameter("ymax", ymax)); | ||
148 | |||
149 | List<RegionProfileData> rows = new List<RegionProfileData>(); | ||
150 | |||
151 | using (SqlDataReader reader = command.ExecuteReader()) | ||
152 | { | ||
153 | while (reader.Read()) | ||
154 | { | ||
155 | rows.Add(ReadSimRow(reader)); | ||
156 | } | ||
157 | } | ||
158 | |||
159 | if (rows.Count > 0) | ||
160 | { | ||
161 | return rows.ToArray(); | ||
162 | } | ||
163 | } | ||
164 | m_log.Info("[GRID DB] : Found no regions within range."); | ||
165 | return null; | ||
166 | } | ||
167 | |||
168 | |||
169 | /// <summary> | ||
170 | /// Returns up to maxNum profiles of regions that have a name starting with namePrefix | ||
171 | /// </summary> | ||
172 | /// <param name="namePrefix">The name to match against</param> | ||
173 | /// <param name="maxNum">Maximum number of profiles to return</param> | ||
174 | /// <returns>A list of sim profiles</returns> | ||
175 | override public List<RegionProfileData> GetRegionsByName (string namePrefix, uint maxNum) | ||
176 | { | ||
177 | using (AutoClosingSqlCommand command = database.Query("SELECT * FROM regions WHERE regionName LIKE @name")) | ||
178 | { | ||
179 | command.Parameters.Add(database.CreateParameter("name", namePrefix + "%")); | ||
180 | |||
181 | List<RegionProfileData> rows = new List<RegionProfileData>(); | ||
182 | |||
183 | using (SqlDataReader reader = command.ExecuteReader()) | ||
184 | { | ||
185 | while (rows.Count < maxNum && reader.Read()) | ||
186 | { | ||
187 | rows.Add(ReadSimRow(reader)); | ||
188 | } | ||
189 | } | ||
190 | |||
191 | return rows; | ||
192 | } | ||
193 | } | ||
194 | |||
195 | /// <summary> | ||
196 | /// Returns a sim profile from its location | ||
197 | /// </summary> | ||
198 | /// <param name="handle">Region location handle</param> | ||
199 | /// <returns>Sim profile</returns> | ||
200 | override public RegionProfileData GetProfileByHandle(ulong handle) | ||
201 | { | ||
202 | using (AutoClosingSqlCommand command = database.Query("SELECT * FROM " + m_regionsTableName + " WHERE regionHandle = @handle")) | ||
203 | { | ||
204 | command.Parameters.Add(database.CreateParameter("handle", handle)); | ||
205 | |||
206 | using (SqlDataReader reader = command.ExecuteReader()) | ||
207 | { | ||
208 | if (reader.Read()) | ||
209 | { | ||
210 | return ReadSimRow(reader); | ||
211 | } | ||
212 | } | ||
213 | } | ||
214 | m_log.InfoFormat("[GRID DB] : No region found with handle : {0}", handle); | ||
215 | return null; | ||
216 | } | ||
217 | |||
218 | /// <summary> | ||
219 | /// Returns a sim profile from its UUID | ||
220 | /// </summary> | ||
221 | /// <param name="uuid">The region UUID</param> | ||
222 | /// <returns>The sim profile</returns> | ||
223 | override public RegionProfileData GetProfileByUUID(UUID uuid) | ||
224 | { | ||
225 | using (AutoClosingSqlCommand command = database.Query("SELECT * FROM " + m_regionsTableName + " WHERE uuid = @uuid")) | ||
226 | { | ||
227 | command.Parameters.Add(database.CreateParameter("uuid", uuid)); | ||
228 | |||
229 | using (SqlDataReader reader = command.ExecuteReader()) | ||
230 | { | ||
231 | if (reader.Read()) | ||
232 | { | ||
233 | return ReadSimRow(reader); | ||
234 | } | ||
235 | } | ||
236 | } | ||
237 | m_log.InfoFormat("[GRID DB] : No region found with UUID : {0}", uuid); | ||
238 | return null; | ||
239 | } | ||
240 | |||
241 | /// <summary> | ||
242 | /// Returns a sim profile from it's Region name string | ||
243 | /// </summary> | ||
244 | /// <param name="regionName">The region name search query</param> | ||
245 | /// <returns>The sim profile</returns> | ||
246 | override public RegionProfileData GetProfileByString(string regionName) | ||
247 | { | ||
248 | if (regionName.Length > 2) | ||
249 | { | ||
250 | using (AutoClosingSqlCommand command = database.Query("SELECT top 1 * FROM " + m_regionsTableName + " WHERE regionName like @regionName order by regionName")) | ||
251 | { | ||
252 | command.Parameters.Add(database.CreateParameter("regionName", regionName + "%")); | ||
253 | |||
254 | using (SqlDataReader reader = command.ExecuteReader()) | ||
255 | { | ||
256 | if (reader.Read()) | ||
257 | { | ||
258 | return ReadSimRow(reader); | ||
259 | } | ||
260 | } | ||
261 | } | ||
262 | m_log.InfoFormat("[GRID DB] : No region found with regionName : {0}", regionName); | ||
263 | return null; | ||
264 | } | ||
265 | |||
266 | m_log.Error("[GRID DB]: Searched for a Region Name shorter then 3 characters"); | ||
267 | return null; | ||
268 | } | ||
269 | |||
270 | /// <summary> | ||
271 | /// Adds a new specified region to the database | ||
272 | /// </summary> | ||
273 | /// <param name="profile">The profile to add</param> | ||
274 | /// <returns>A dataresponse enum indicating success</returns> | ||
275 | override public DataResponse StoreProfile(RegionProfileData profile) | ||
276 | { | ||
277 | if (GetProfileByUUID(profile.UUID) == null) | ||
278 | { | ||
279 | if (InsertRegionRow(profile)) | ||
280 | { | ||
281 | return DataResponse.RESPONSE_OK; | ||
282 | } | ||
283 | } | ||
284 | else | ||
285 | { | ||
286 | if (UpdateRegionRow(profile)) | ||
287 | { | ||
288 | return DataResponse.RESPONSE_OK; | ||
289 | } | ||
290 | } | ||
291 | |||
292 | return DataResponse.RESPONSE_ERROR; | ||
293 | } | ||
294 | |||
295 | /// <summary> | ||
296 | /// Deletes a sim profile from the database | ||
297 | /// </summary> | ||
298 | /// <param name="uuid">the sim UUID</param> | ||
299 | /// <returns>Successful?</returns> | ||
300 | //public DataResponse DeleteProfile(RegionProfileData profile) | ||
301 | override public DataResponse DeleteProfile(string uuid) | ||
302 | { | ||
303 | using (AutoClosingSqlCommand command = database.Query("DELETE FROM regions WHERE uuid = @uuid;")) | ||
304 | { | ||
305 | command.Parameters.Add(database.CreateParameter("uuid", uuid)); | ||
306 | try | ||
307 | { | ||
308 | command.ExecuteNonQuery(); | ||
309 | return DataResponse.RESPONSE_OK; | ||
310 | } | ||
311 | catch (Exception e) | ||
312 | { | ||
313 | m_log.DebugFormat("[GRID DB] : Error deleting region info, error is : {0}", e.Message); | ||
314 | return DataResponse.RESPONSE_ERROR; | ||
315 | } | ||
316 | } | ||
317 | } | ||
318 | |||
319 | #endregion | ||
320 | |||
321 | #region Methods that are not used or deprecated (still needed because of base class) | ||
322 | |||
323 | /// <summary> | ||
324 | /// DEPRECATED. Attempts to authenticate a region by comparing a shared secret. | ||
325 | /// </summary> | ||
326 | /// <param name="uuid">The UUID of the challenger</param> | ||
327 | /// <param name="handle">The attempted regionHandle of the challenger</param> | ||
328 | /// <param name="authkey">The secret</param> | ||
329 | /// <returns>Whether the secret and regionhandle match the database entry for UUID</returns> | ||
330 | override public bool AuthenticateSim(UUID uuid, ulong handle, string authkey) | ||
331 | { | ||
332 | bool throwHissyFit = false; // Should be true by 1.0 | ||
333 | |||
334 | if (throwHissyFit) | ||
335 | throw new Exception("CRYPTOWEAK AUTHENTICATE: Refusing to authenticate due to replay potential."); | ||
336 | |||
337 | RegionProfileData data = GetProfileByUUID(uuid); | ||
338 | |||
339 | return (handle == data.regionHandle && authkey == data.regionSecret); | ||
340 | } | ||
341 | |||
342 | /// <summary> | ||
343 | /// NOT YET FUNCTIONAL. Provides a cryptographic authentication of a region | ||
344 | /// </summary> | ||
345 | /// <remarks>This requires a security audit.</remarks> | ||
346 | /// <param name="uuid"></param> | ||
347 | /// <param name="handle"></param> | ||
348 | /// <param name="authhash"></param> | ||
349 | /// <param name="challenge"></param> | ||
350 | /// <returns></returns> | ||
351 | public bool AuthenticateSim(UUID uuid, ulong handle, string authhash, string challenge) | ||
352 | { | ||
353 | // SHA512Managed HashProvider = new SHA512Managed(); | ||
354 | // Encoding TextProvider = new UTF8Encoding(); | ||
355 | |||
356 | // byte[] stream = TextProvider.GetBytes(uuid.ToString() + ":" + handle.ToString() + ":" + challenge); | ||
357 | // byte[] hash = HashProvider.ComputeHash(stream); | ||
358 | return false; | ||
359 | } | ||
360 | |||
361 | /// <summary> | ||
362 | /// NOT IMPLEMENTED | ||
363 | /// WHEN IS THIS GONNA BE IMPLEMENTED. | ||
364 | /// </summary> | ||
365 | /// <param name="x"></param> | ||
366 | /// <param name="y"></param> | ||
367 | /// <returns>null</returns> | ||
368 | override public ReservationData GetReservationAtPoint(uint x, uint y) | ||
369 | { | ||
370 | return null; | ||
371 | } | ||
372 | |||
373 | #endregion | ||
374 | |||
375 | #region private methods | ||
376 | |||
377 | /// <summary> | ||
378 | /// Reads a region row from a database reader | ||
379 | /// </summary> | ||
380 | /// <param name="reader">An active database reader</param> | ||
381 | /// <returns>A region profile</returns> | ||
382 | private static RegionProfileData ReadSimRow(IDataRecord reader) | ||
383 | { | ||
384 | RegionProfileData retval = new RegionProfileData(); | ||
385 | |||
386 | // Region Main gotta-have-or-we-return-null parts | ||
387 | UInt64 tmp64; | ||
388 | if (!UInt64.TryParse(reader["regionHandle"].ToString(), out tmp64)) | ||
389 | { | ||
390 | return null; | ||
391 | } | ||
392 | |||
393 | retval.regionHandle = tmp64; | ||
394 | |||
395 | // UUID tmp_uuid; | ||
396 | // if (!UUID.TryParse((string)reader["uuid"], out tmp_uuid)) | ||
397 | // { | ||
398 | // return null; | ||
399 | // } | ||
400 | |||
401 | retval.UUID = new UUID((Guid)reader["uuid"]); // tmp_uuid; | ||
402 | |||
403 | // non-critical parts | ||
404 | retval.regionName = reader["regionName"].ToString(); | ||
405 | retval.originUUID = new UUID((Guid)reader["originUUID"]); | ||
406 | |||
407 | // Secrets | ||
408 | retval.regionRecvKey = reader["regionRecvKey"].ToString(); | ||
409 | retval.regionSecret = reader["regionSecret"].ToString(); | ||
410 | retval.regionSendKey = reader["regionSendKey"].ToString(); | ||
411 | |||
412 | // Region Server | ||
413 | retval.regionDataURI = reader["regionDataURI"].ToString(); | ||
414 | retval.regionOnline = false; // Needs to be pinged before this can be set. | ||
415 | retval.serverIP = reader["serverIP"].ToString(); | ||
416 | retval.serverPort = Convert.ToUInt32(reader["serverPort"]); | ||
417 | retval.serverURI = reader["serverURI"].ToString(); | ||
418 | retval.httpPort = Convert.ToUInt32(reader["serverHttpPort"].ToString()); | ||
419 | retval.remotingPort = Convert.ToUInt32(reader["serverRemotingPort"].ToString()); | ||
420 | |||
421 | // Location | ||
422 | retval.regionLocX = Convert.ToUInt32(reader["locX"].ToString()); | ||
423 | retval.regionLocY = Convert.ToUInt32(reader["locY"].ToString()); | ||
424 | retval.regionLocZ = Convert.ToUInt32(reader["locZ"].ToString()); | ||
425 | |||
426 | // Neighbours - 0 = No Override | ||
427 | retval.regionEastOverrideHandle = Convert.ToUInt64(reader["eastOverrideHandle"].ToString()); | ||
428 | retval.regionWestOverrideHandle = Convert.ToUInt64(reader["westOverrideHandle"].ToString()); | ||
429 | retval.regionSouthOverrideHandle = Convert.ToUInt64(reader["southOverrideHandle"].ToString()); | ||
430 | retval.regionNorthOverrideHandle = Convert.ToUInt64(reader["northOverrideHandle"].ToString()); | ||
431 | |||
432 | // Assets | ||
433 | retval.regionAssetURI = reader["regionAssetURI"].ToString(); | ||
434 | retval.regionAssetRecvKey = reader["regionAssetRecvKey"].ToString(); | ||
435 | retval.regionAssetSendKey = reader["regionAssetSendKey"].ToString(); | ||
436 | |||
437 | // Userserver | ||
438 | retval.regionUserURI = reader["regionUserURI"].ToString(); | ||
439 | retval.regionUserRecvKey = reader["regionUserRecvKey"].ToString(); | ||
440 | retval.regionUserSendKey = reader["regionUserSendKey"].ToString(); | ||
441 | |||
442 | // World Map Addition | ||
443 | retval.regionMapTextureID = new UUID((Guid)reader["regionMapTexture"]); | ||
444 | retval.owner_uuid = new UUID((Guid)reader["owner_uuid"]); | ||
445 | retval.maturity = Convert.ToUInt32(reader["access"]); | ||
446 | return retval; | ||
447 | } | ||
448 | |||
449 | /// <summary> | ||
450 | /// Update the specified region in the database | ||
451 | /// </summary> | ||
452 | /// <param name="profile">The profile to update</param> | ||
453 | /// <returns>success ?</returns> | ||
454 | private bool UpdateRegionRow(RegionProfileData profile) | ||
455 | { | ||
456 | bool returnval = false; | ||
457 | |||
458 | //Insert new region | ||
459 | string sql = | ||
460 | "UPDATE " + m_regionsTableName + @" SET | ||
461 | [regionHandle]=@regionHandle, [regionName]=@regionName, | ||
462 | [regionRecvKey]=@regionRecvKey, [regionSecret]=@regionSecret, [regionSendKey]=@regionSendKey, | ||
463 | [regionDataURI]=@regionDataURI, [serverIP]=@serverIP, [serverPort]=@serverPort, [serverURI]=@serverURI, | ||
464 | [locX]=@locX, [locY]=@locY, [locZ]=@locZ, [eastOverrideHandle]=@eastOverrideHandle, | ||
465 | [westOverrideHandle]=@westOverrideHandle, [southOverrideHandle]=@southOverrideHandle, | ||
466 | [northOverrideHandle]=@northOverrideHandle, [regionAssetURI]=@regionAssetURI, | ||
467 | [regionAssetRecvKey]=@regionAssetRecvKey, [regionAssetSendKey]=@regionAssetSendKey, | ||
468 | [regionUserURI]=@regionUserURI, [regionUserRecvKey]=@regionUserRecvKey, [regionUserSendKey]=@regionUserSendKey, | ||
469 | [regionMapTexture]=@regionMapTexture, [serverHttpPort]=@serverHttpPort, | ||
470 | [serverRemotingPort]=@serverRemotingPort, [owner_uuid]=@owner_uuid , [originUUID]=@originUUID | ||
471 | where [uuid]=@uuid"; | ||
472 | |||
473 | using (AutoClosingSqlCommand command = database.Query(sql)) | ||
474 | { | ||
475 | command.Parameters.Add(database.CreateParameter("regionHandle", profile.regionHandle)); | ||
476 | command.Parameters.Add(database.CreateParameter("regionName", profile.regionName)); | ||
477 | command.Parameters.Add(database.CreateParameter("uuid", profile.UUID)); | ||
478 | command.Parameters.Add(database.CreateParameter("regionRecvKey", profile.regionRecvKey)); | ||
479 | command.Parameters.Add(database.CreateParameter("regionSecret", profile.regionSecret)); | ||
480 | command.Parameters.Add(database.CreateParameter("regionSendKey", profile.regionSendKey)); | ||
481 | command.Parameters.Add(database.CreateParameter("regionDataURI", profile.regionDataURI)); | ||
482 | command.Parameters.Add(database.CreateParameter("serverIP", profile.serverIP)); | ||
483 | command.Parameters.Add(database.CreateParameter("serverPort", profile.serverPort)); | ||
484 | command.Parameters.Add(database.CreateParameter("serverURI", profile.serverURI)); | ||
485 | command.Parameters.Add(database.CreateParameter("locX", profile.regionLocX)); | ||
486 | command.Parameters.Add(database.CreateParameter("locY", profile.regionLocY)); | ||
487 | command.Parameters.Add(database.CreateParameter("locZ", profile.regionLocZ)); | ||
488 | command.Parameters.Add(database.CreateParameter("eastOverrideHandle", profile.regionEastOverrideHandle)); | ||
489 | command.Parameters.Add(database.CreateParameter("westOverrideHandle", profile.regionWestOverrideHandle)); | ||
490 | command.Parameters.Add(database.CreateParameter("northOverrideHandle", profile.regionNorthOverrideHandle)); | ||
491 | command.Parameters.Add(database.CreateParameter("southOverrideHandle", profile.regionSouthOverrideHandle)); | ||
492 | command.Parameters.Add(database.CreateParameter("regionAssetURI", profile.regionAssetURI)); | ||
493 | command.Parameters.Add(database.CreateParameter("regionAssetRecvKey", profile.regionAssetRecvKey)); | ||
494 | command.Parameters.Add(database.CreateParameter("regionAssetSendKey", profile.regionAssetSendKey)); | ||
495 | command.Parameters.Add(database.CreateParameter("regionUserURI", profile.regionUserURI)); | ||
496 | command.Parameters.Add(database.CreateParameter("regionUserRecvKey", profile.regionUserRecvKey)); | ||
497 | command.Parameters.Add(database.CreateParameter("regionUserSendKey", profile.regionUserSendKey)); | ||
498 | command.Parameters.Add(database.CreateParameter("regionMapTexture", profile.regionMapTextureID)); | ||
499 | command.Parameters.Add(database.CreateParameter("serverHttpPort", profile.httpPort)); | ||
500 | command.Parameters.Add(database.CreateParameter("serverRemotingPort", profile.remotingPort)); | ||
501 | command.Parameters.Add(database.CreateParameter("owner_uuid", profile.owner_uuid)); | ||
502 | command.Parameters.Add(database.CreateParameter("originUUID", profile.originUUID)); | ||
503 | |||
504 | try | ||
505 | { | ||
506 | command.ExecuteNonQuery(); | ||
507 | returnval = true; | ||
508 | } | ||
509 | catch (Exception e) | ||
510 | { | ||
511 | m_log.Error("[GRID DB] : Error updating region, error: " + e.Message); | ||
512 | } | ||
513 | } | ||
514 | |||
515 | return returnval; | ||
516 | } | ||
517 | |||
518 | /// <summary> | ||
519 | /// Creates a new region in the database | ||
520 | /// </summary> | ||
521 | /// <param name="profile">The region profile to insert</param> | ||
522 | /// <returns>Successful?</returns> | ||
523 | private bool InsertRegionRow(RegionProfileData profile) | ||
524 | { | ||
525 | bool returnval = false; | ||
526 | |||
527 | //Insert new region | ||
528 | string sql = | ||
529 | "INSERT INTO " + m_regionsTableName + @" ([regionHandle], [regionName], [uuid], [regionRecvKey], [regionSecret], [regionSendKey], [regionDataURI], | ||
530 | [serverIP], [serverPort], [serverURI], [locX], [locY], [locZ], [eastOverrideHandle], [westOverrideHandle], | ||
531 | [southOverrideHandle], [northOverrideHandle], [regionAssetURI], [regionAssetRecvKey], [regionAssetSendKey], | ||
532 | [regionUserURI], [regionUserRecvKey], [regionUserSendKey], [regionMapTexture], [serverHttpPort], | ||
533 | [serverRemotingPort], [owner_uuid], [originUUID], [access]) | ||
534 | VALUES (@regionHandle, @regionName, @uuid, @regionRecvKey, @regionSecret, @regionSendKey, @regionDataURI, | ||
535 | @serverIP, @serverPort, @serverURI, @locX, @locY, @locZ, @eastOverrideHandle, @westOverrideHandle, | ||
536 | @southOverrideHandle, @northOverrideHandle, @regionAssetURI, @regionAssetRecvKey, @regionAssetSendKey, | ||
537 | @regionUserURI, @regionUserRecvKey, @regionUserSendKey, @regionMapTexture, @serverHttpPort, @serverRemotingPort, @owner_uuid, @originUUID, @access);"; | ||
538 | |||
539 | using (AutoClosingSqlCommand command = database.Query(sql)) | ||
540 | { | ||
541 | command.Parameters.Add(database.CreateParameter("regionHandle", profile.regionHandle)); | ||
542 | command.Parameters.Add(database.CreateParameter("regionName", profile.regionName)); | ||
543 | command.Parameters.Add(database.CreateParameter("uuid", profile.UUID)); | ||
544 | command.Parameters.Add(database.CreateParameter("regionRecvKey", profile.regionRecvKey)); | ||
545 | command.Parameters.Add(database.CreateParameter("regionSecret", profile.regionSecret)); | ||
546 | command.Parameters.Add(database.CreateParameter("regionSendKey", profile.regionSendKey)); | ||
547 | command.Parameters.Add(database.CreateParameter("regionDataURI", profile.regionDataURI)); | ||
548 | command.Parameters.Add(database.CreateParameter("serverIP", profile.serverIP)); | ||
549 | command.Parameters.Add(database.CreateParameter("serverPort", profile.serverPort)); | ||
550 | command.Parameters.Add(database.CreateParameter("serverURI", profile.serverURI)); | ||
551 | command.Parameters.Add(database.CreateParameter("locX", profile.regionLocX)); | ||
552 | command.Parameters.Add(database.CreateParameter("locY", profile.regionLocY)); | ||
553 | command.Parameters.Add(database.CreateParameter("locZ", profile.regionLocZ)); | ||
554 | command.Parameters.Add(database.CreateParameter("eastOverrideHandle", profile.regionEastOverrideHandle)); | ||
555 | command.Parameters.Add(database.CreateParameter("westOverrideHandle", profile.regionWestOverrideHandle)); | ||
556 | command.Parameters.Add(database.CreateParameter("northOverrideHandle", profile.regionNorthOverrideHandle)); | ||
557 | command.Parameters.Add(database.CreateParameter("southOverrideHandle", profile.regionSouthOverrideHandle)); | ||
558 | command.Parameters.Add(database.CreateParameter("regionAssetURI", profile.regionAssetURI)); | ||
559 | command.Parameters.Add(database.CreateParameter("regionAssetRecvKey", profile.regionAssetRecvKey)); | ||
560 | command.Parameters.Add(database.CreateParameter("regionAssetSendKey", profile.regionAssetSendKey)); | ||
561 | command.Parameters.Add(database.CreateParameter("regionUserURI", profile.regionUserURI)); | ||
562 | command.Parameters.Add(database.CreateParameter("regionUserRecvKey", profile.regionUserRecvKey)); | ||
563 | command.Parameters.Add(database.CreateParameter("regionUserSendKey", profile.regionUserSendKey)); | ||
564 | command.Parameters.Add(database.CreateParameter("regionMapTexture", profile.regionMapTextureID)); | ||
565 | command.Parameters.Add(database.CreateParameter("serverHttpPort", profile.httpPort)); | ||
566 | command.Parameters.Add(database.CreateParameter("serverRemotingPort", profile.remotingPort)); | ||
567 | command.Parameters.Add(database.CreateParameter("owner_uuid", profile.owner_uuid)); | ||
568 | command.Parameters.Add(database.CreateParameter("originUUID", profile.originUUID)); | ||
569 | command.Parameters.Add(database.CreateParameter("access", profile.maturity)); | ||
570 | |||
571 | try | ||
572 | { | ||
573 | command.ExecuteNonQuery(); | ||
574 | returnval = true; | ||
575 | } | ||
576 | catch (Exception e) | ||
577 | { | ||
578 | m_log.Error("[GRID DB] : Error inserting region, error: " + e.Message); | ||
579 | } | ||
580 | } | ||
581 | |||
582 | return returnval; | ||
583 | } | ||
584 | |||
585 | #endregion | ||
586 | } | ||
587 | } | ||
diff --git a/OpenSim/Data/MSSQL/MSSQLLogData.cs b/OpenSim/Data/MSSQL/MSSQLLogData.cs deleted file mode 100644 index 72c50e6..0000000 --- a/OpenSim/Data/MSSQL/MSSQLLogData.cs +++ /dev/null | |||
@@ -1,146 +0,0 @@ | |||
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 log4net; | ||
31 | using OpenSim.Framework; | ||
32 | |||
33 | namespace OpenSim.Data.MSSQL | ||
34 | { | ||
35 | /// <summary> | ||
36 | /// An interface to the log database for MSSQL | ||
37 | /// </summary> | ||
38 | internal class MSSQLLogData : ILogDataPlugin | ||
39 | { | ||
40 | private const string _migrationStore = "LogStore"; | ||
41 | |||
42 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
43 | |||
44 | /// <summary> | ||
45 | /// The database manager | ||
46 | /// </summary> | ||
47 | public MSSQLManager database; | ||
48 | |||
49 | [Obsolete("Cannot be default-initialized!")] | ||
50 | public void Initialise() | ||
51 | { | ||
52 | m_log.Info("[LOG DB]: " + Name + " cannot be default-initialized!"); | ||
53 | throw new PluginNotInitialisedException (Name); | ||
54 | } | ||
55 | |||
56 | /// <summary> | ||
57 | /// Artificial constructor called when the plugin is loaded | ||
58 | /// </summary> | ||
59 | public void Initialise(string connect) | ||
60 | { | ||
61 | if (!string.IsNullOrEmpty(connect)) | ||
62 | { | ||
63 | database = new MSSQLManager(connect); | ||
64 | } | ||
65 | else | ||
66 | { | ||
67 | // TODO: do something with the connect string | ||
68 | IniFile gridDataMSSqlFile = new IniFile("mssql_connection.ini"); | ||
69 | string settingDataSource = gridDataMSSqlFile.ParseFileReadValue("data_source"); | ||
70 | string settingInitialCatalog = gridDataMSSqlFile.ParseFileReadValue("initial_catalog"); | ||
71 | string settingPersistSecurityInfo = gridDataMSSqlFile.ParseFileReadValue("persist_security_info"); | ||
72 | string settingUserId = gridDataMSSqlFile.ParseFileReadValue("user_id"); | ||
73 | string settingPassword = gridDataMSSqlFile.ParseFileReadValue("password"); | ||
74 | |||
75 | database = | ||
76 | new MSSQLManager(settingDataSource, settingInitialCatalog, settingPersistSecurityInfo, settingUserId, | ||
77 | settingPassword); | ||
78 | } | ||
79 | |||
80 | //Updating mechanisme | ||
81 | database.CheckMigration(_migrationStore); | ||
82 | } | ||
83 | |||
84 | /// <summary> | ||
85 | /// Saves a log item to the database | ||
86 | /// </summary> | ||
87 | /// <param name="serverDaemon">The daemon triggering the event</param> | ||
88 | /// <param name="target">The target of the action (region / agent UUID, etc)</param> | ||
89 | /// <param name="methodCall">The method call where the problem occured</param> | ||
90 | /// <param name="arguments">The arguments passed to the method</param> | ||
91 | /// <param name="priority">How critical is this?</param> | ||
92 | /// <param name="logMessage">The message to log</param> | ||
93 | public void saveLog(string serverDaemon, string target, string methodCall, string arguments, int priority, | ||
94 | string logMessage) | ||
95 | { | ||
96 | string sql = "INSERT INTO logs ([target], [server], [method], [arguments], [priority], [message]) VALUES "; | ||
97 | sql += "(@target, @server, @method, @arguments, @priority, @message);"; | ||
98 | |||
99 | using (AutoClosingSqlCommand command = database.Query(sql)) | ||
100 | { | ||
101 | command.Parameters.Add(database.CreateParameter("server", serverDaemon)); | ||
102 | command.Parameters.Add(database.CreateParameter("target",target)); | ||
103 | command.Parameters.Add(database.CreateParameter("method", methodCall)); | ||
104 | command.Parameters.Add(database.CreateParameter("arguments", arguments)); | ||
105 | command.Parameters.Add(database.CreateParameter("priority", priority.ToString())); | ||
106 | command.Parameters.Add(database.CreateParameter("message", logMessage)); | ||
107 | |||
108 | try | ||
109 | { | ||
110 | command.ExecuteNonQuery(); | ||
111 | } | ||
112 | catch (Exception e) | ||
113 | { | ||
114 | //Are we not in a loop here | ||
115 | m_log.Error("[LOG DB] Error logging : " + e.Message); | ||
116 | } | ||
117 | } | ||
118 | } | ||
119 | |||
120 | /// <summary> | ||
121 | /// Returns the name of this DB provider | ||
122 | /// </summary> | ||
123 | /// <returns>A string containing the DB provider name</returns> | ||
124 | public string Name | ||
125 | { | ||
126 | get { return "MSSQL Logdata Interface"; } | ||
127 | } | ||
128 | |||
129 | /// <summary> | ||
130 | /// Closes the database provider | ||
131 | /// </summary> | ||
132 | public void Dispose() | ||
133 | { | ||
134 | database = null; | ||
135 | } | ||
136 | |||
137 | /// <summary> | ||
138 | /// Returns the version of this DB provider | ||
139 | /// </summary> | ||
140 | /// <returns>A string containing the provider version</returns> | ||
141 | public string Version | ||
142 | { | ||
143 | get { return "0.1"; } | ||
144 | } | ||
145 | } | ||
146 | } | ||
diff --git a/OpenSim/Data/MSSQL/MSSQLUserData.cs b/OpenSim/Data/MSSQL/MSSQLUserData.cs deleted file mode 100644 index 3ef1053..0000000 --- a/OpenSim/Data/MSSQL/MSSQLUserData.cs +++ /dev/null | |||
@@ -1,1214 +0,0 @@ | |||
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.Data; | ||
32 | using System.Data.SqlClient; | ||
33 | using System.Reflection; | ||
34 | using log4net; | ||
35 | using OpenMetaverse; | ||
36 | using OpenSim.Framework; | ||
37 | |||
38 | namespace OpenSim.Data.MSSQL | ||
39 | { | ||
40 | /// <summary> | ||
41 | /// A database interface class to a user profile storage system | ||
42 | /// </summary> | ||
43 | public class MSSQLUserData : UserDataBase | ||
44 | { | ||
45 | private const string _migrationStore = "UserStore"; | ||
46 | |||
47 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
48 | |||
49 | /// <summary> | ||
50 | /// Database manager for MSSQL | ||
51 | /// </summary> | ||
52 | public MSSQLManager database; | ||
53 | |||
54 | private const string m_agentsTableName = "agents"; | ||
55 | private const string m_usersTableName = "users"; | ||
56 | private const string m_userFriendsTableName = "userfriends"; | ||
57 | |||
58 | // [Obsolete("Cannot be default-initialized!")] | ||
59 | override public void Initialise() | ||
60 | { | ||
61 | m_log.Info("[MSSQLUserData]: " + Name + " cannot be default-initialized!"); | ||
62 | throw new PluginNotInitialisedException(Name); | ||
63 | } | ||
64 | |||
65 | /// <summary> | ||
66 | /// Loads and initialises the MSSQL storage plugin | ||
67 | /// </summary> | ||
68 | /// <param name="connect">connectionstring</param> | ||
69 | /// <remarks>use mssql_connection.ini</remarks> | ||
70 | override public void Initialise(string connect) | ||
71 | { | ||
72 | if (!string.IsNullOrEmpty(connect)) | ||
73 | { | ||
74 | database = new MSSQLManager(connect); | ||
75 | } | ||
76 | else | ||
77 | { | ||
78 | IniFile iniFile = new IniFile("mssql_connection.ini"); | ||
79 | |||
80 | string settingDataSource = iniFile.ParseFileReadValue("data_source"); | ||
81 | string settingInitialCatalog = iniFile.ParseFileReadValue("initial_catalog"); | ||
82 | string settingPersistSecurityInfo = iniFile.ParseFileReadValue("persist_security_info"); | ||
83 | string settingUserId = iniFile.ParseFileReadValue("user_id"); | ||
84 | string settingPassword = iniFile.ParseFileReadValue("password"); | ||
85 | |||
86 | database = new MSSQLManager(settingDataSource, settingInitialCatalog, settingPersistSecurityInfo, settingUserId, settingPassword); | ||
87 | } | ||
88 | |||
89 | //Check migration on DB | ||
90 | database.CheckMigration(_migrationStore); | ||
91 | } | ||
92 | |||
93 | /// <summary> | ||
94 | /// Releases unmanaged and - optionally - managed resources | ||
95 | /// </summary> | ||
96 | override public void Dispose() { } | ||
97 | |||
98 | #region User table methods | ||
99 | |||
100 | /// <summary> | ||
101 | /// Searches the database for a specified user profile by name components | ||
102 | /// </summary> | ||
103 | /// <param name="user">The first part of the account name</param> | ||
104 | /// <param name="last">The second part of the account name</param> | ||
105 | /// <returns>A user profile</returns> | ||
106 | override public UserProfileData GetUserByName(string user, string last) | ||
107 | { | ||
108 | string sql = string.Format(@"SELECT * FROM {0} | ||
109 | WHERE username = @first AND lastname = @second", m_usersTableName); | ||
110 | using (AutoClosingSqlCommand command = database.Query(sql)) | ||
111 | { | ||
112 | command.Parameters.Add(database.CreateParameter("first", user)); | ||
113 | command.Parameters.Add(database.CreateParameter("second", last)); | ||
114 | try | ||
115 | { | ||
116 | using (SqlDataReader reader = command.ExecuteReader()) | ||
117 | { | ||
118 | return ReadUserRow(reader); | ||
119 | } | ||
120 | } | ||
121 | catch (Exception e) | ||
122 | { | ||
123 | m_log.ErrorFormat("[USER DB] Error getting user profile for {0} {1}: {2}", user, last, e.Message); | ||
124 | return null; | ||
125 | } | ||
126 | } | ||
127 | } | ||
128 | |||
129 | /// <summary> | ||
130 | /// See IUserDataPlugin | ||
131 | /// </summary> | ||
132 | /// <param name="uuid"></param> | ||
133 | /// <returns></returns> | ||
134 | override public UserProfileData GetUserByUUID(UUID uuid) | ||
135 | { | ||
136 | string sql = string.Format("SELECT * FROM {0} WHERE UUID = @uuid", m_usersTableName); | ||
137 | using (AutoClosingSqlCommand command = database.Query(sql)) | ||
138 | { | ||
139 | command.Parameters.Add(database.CreateParameter("uuid", uuid)); | ||
140 | try | ||
141 | { | ||
142 | using (SqlDataReader reader = command.ExecuteReader()) | ||
143 | { | ||
144 | return ReadUserRow(reader); | ||
145 | } | ||
146 | } | ||
147 | catch (Exception e) | ||
148 | { | ||
149 | m_log.ErrorFormat("[USER DB] Error getting user profile by UUID {0}, error: {1}", uuid, e.Message); | ||
150 | return null; | ||
151 | } | ||
152 | } | ||
153 | } | ||
154 | |||
155 | |||
156 | /// <summary> | ||
157 | /// Creates a new users profile | ||
158 | /// </summary> | ||
159 | /// <param name="user">The user profile to create</param> | ||
160 | override public void AddNewUserProfile(UserProfileData user) | ||
161 | { | ||
162 | try | ||
163 | { | ||
164 | InsertUserRow(user.ID, user.FirstName, user.SurName, user.Email, user.PasswordHash, user.PasswordSalt, | ||
165 | user.HomeRegion, user.HomeLocation.X, user.HomeLocation.Y, | ||
166 | user.HomeLocation.Z, | ||
167 | user.HomeLookAt.X, user.HomeLookAt.Y, user.HomeLookAt.Z, user.Created, | ||
168 | user.LastLogin, user.UserInventoryURI, user.UserAssetURI, | ||
169 | user.CanDoMask, user.WantDoMask, | ||
170 | user.AboutText, user.FirstLifeAboutText, user.Image, | ||
171 | user.FirstLifeImage, user.WebLoginKey, user.HomeRegionID, | ||
172 | user.GodLevel, user.UserFlags, user.CustomType, user.Partner); | ||
173 | } | ||
174 | catch (Exception e) | ||
175 | { | ||
176 | m_log.ErrorFormat("[USER DB] Error adding new profile, error: {0}", e.Message); | ||
177 | } | ||
178 | } | ||
179 | |||
180 | /// <summary> | ||
181 | /// update a user profile | ||
182 | /// </summary> | ||
183 | /// <param name="user">the profile to update</param> | ||
184 | /// <returns></returns> | ||
185 | override public bool UpdateUserProfile(UserProfileData user) | ||
186 | { | ||
187 | string sql = string.Format(@"UPDATE {0} | ||
188 | SET UUID = @uuid, | ||
189 | username = @username, | ||
190 | lastname = @lastname, | ||
191 | email = @email, | ||
192 | passwordHash = @passwordHash, | ||
193 | passwordSalt = @passwordSalt, | ||
194 | homeRegion = @homeRegion, | ||
195 | homeLocationX = @homeLocationX, | ||
196 | homeLocationY = @homeLocationY, | ||
197 | homeLocationZ = @homeLocationZ, | ||
198 | homeLookAtX = @homeLookAtX, | ||
199 | homeLookAtY = @homeLookAtY, | ||
200 | homeLookAtZ = @homeLookAtZ, | ||
201 | created = @created, | ||
202 | lastLogin = @lastLogin, | ||
203 | userInventoryURI = @userInventoryURI, | ||
204 | userAssetURI = @userAssetURI, | ||
205 | profileCanDoMask = @profileCanDoMask, | ||
206 | profileWantDoMask = @profileWantDoMask, | ||
207 | profileAboutText = @profileAboutText, | ||
208 | profileFirstText = @profileFirstText, | ||
209 | profileImage = @profileImage, | ||
210 | profileFirstImage = @profileFirstImage, | ||
211 | webLoginKey = @webLoginKey, | ||
212 | homeRegionID = @homeRegionID, | ||
213 | userFlags = @userFlags, | ||
214 | godLevel = @godLevel, | ||
215 | customType = @customType, | ||
216 | partner = @partner WHERE UUID = @keyUUUID;",m_usersTableName); | ||
217 | using (AutoClosingSqlCommand command = database.Query(sql)) | ||
218 | { | ||
219 | command.Parameters.Add(database.CreateParameter("uuid", user.ID)); | ||
220 | command.Parameters.Add(database.CreateParameter("username", user.FirstName)); | ||
221 | command.Parameters.Add(database.CreateParameter("lastname", user.SurName)); | ||
222 | command.Parameters.Add(database.CreateParameter("email", user.Email)); | ||
223 | command.Parameters.Add(database.CreateParameter("passwordHash", user.PasswordHash)); | ||
224 | command.Parameters.Add(database.CreateParameter("passwordSalt", user.PasswordSalt)); | ||
225 | command.Parameters.Add(database.CreateParameter("homeRegion", user.HomeRegion)); | ||
226 | command.Parameters.Add(database.CreateParameter("homeLocationX", user.HomeLocation.X)); | ||
227 | command.Parameters.Add(database.CreateParameter("homeLocationY", user.HomeLocation.Y)); | ||
228 | command.Parameters.Add(database.CreateParameter("homeLocationZ", user.HomeLocation.Z)); | ||
229 | command.Parameters.Add(database.CreateParameter("homeLookAtX", user.HomeLookAt.X)); | ||
230 | command.Parameters.Add(database.CreateParameter("homeLookAtY", user.HomeLookAt.Y)); | ||
231 | command.Parameters.Add(database.CreateParameter("homeLookAtZ", user.HomeLookAt.Z)); | ||
232 | command.Parameters.Add(database.CreateParameter("created", user.Created)); | ||
233 | command.Parameters.Add(database.CreateParameter("lastLogin", user.LastLogin)); | ||
234 | command.Parameters.Add(database.CreateParameter("userInventoryURI", user.UserInventoryURI)); | ||
235 | command.Parameters.Add(database.CreateParameter("userAssetURI", user.UserAssetURI)); | ||
236 | command.Parameters.Add(database.CreateParameter("profileCanDoMask", user.CanDoMask)); | ||
237 | command.Parameters.Add(database.CreateParameter("profileWantDoMask", user.WantDoMask)); | ||
238 | command.Parameters.Add(database.CreateParameter("profileAboutText", user.AboutText)); | ||
239 | command.Parameters.Add(database.CreateParameter("profileFirstText", user.FirstLifeAboutText)); | ||
240 | command.Parameters.Add(database.CreateParameter("profileImage", user.Image)); | ||
241 | command.Parameters.Add(database.CreateParameter("profileFirstImage", user.FirstLifeImage)); | ||
242 | command.Parameters.Add(database.CreateParameter("webLoginKey", user.WebLoginKey)); | ||
243 | command.Parameters.Add(database.CreateParameter("homeRegionID", user.HomeRegionID)); | ||
244 | command.Parameters.Add(database.CreateParameter("userFlags", user.UserFlags)); | ||
245 | command.Parameters.Add(database.CreateParameter("godLevel", user.GodLevel)); | ||
246 | command.Parameters.Add(database.CreateParameter("customType", user.CustomType)); | ||
247 | command.Parameters.Add(database.CreateParameter("partner", user.Partner)); | ||
248 | command.Parameters.Add(database.CreateParameter("keyUUUID", user.ID)); | ||
249 | |||
250 | try | ||
251 | { | ||
252 | int affected = command.ExecuteNonQuery(); | ||
253 | return (affected != 0); | ||
254 | } | ||
255 | catch (Exception e) | ||
256 | { | ||
257 | m_log.ErrorFormat("[USER DB] Error updating profile, error: {0}", e.Message); | ||
258 | } | ||
259 | } | ||
260 | return false; | ||
261 | } | ||
262 | |||
263 | #endregion | ||
264 | |||
265 | #region Agent table methods | ||
266 | |||
267 | /// <summary> | ||
268 | /// Returns a user session searching by name | ||
269 | /// </summary> | ||
270 | /// <param name="name">The account name</param> | ||
271 | /// <returns>The users session</returns> | ||
272 | override public UserAgentData GetAgentByName(string name) | ||
273 | { | ||
274 | return GetAgentByName(name.Split(' ')[0], name.Split(' ')[1]); | ||
275 | } | ||
276 | |||
277 | /// <summary> | ||
278 | /// Returns a user session by account name | ||
279 | /// </summary> | ||
280 | /// <param name="user">First part of the users account name</param> | ||
281 | /// <param name="last">Second part of the users account name</param> | ||
282 | /// <returns>The users session</returns> | ||
283 | override public UserAgentData GetAgentByName(string user, string last) | ||
284 | { | ||
285 | UserProfileData profile = GetUserByName(user, last); | ||
286 | return GetAgentByUUID(profile.ID); | ||
287 | } | ||
288 | |||
289 | /// <summary> | ||
290 | /// Returns an agent session by account UUID | ||
291 | /// </summary> | ||
292 | /// <param name="uuid">The accounts UUID</param> | ||
293 | /// <returns>The users session</returns> | ||
294 | override public UserAgentData GetAgentByUUID(UUID uuid) | ||
295 | { | ||
296 | string sql = string.Format("SELECT * FROM {0} WHERE UUID = @uuid", m_agentsTableName); | ||
297 | using (AutoClosingSqlCommand command = database.Query(sql)) | ||
298 | { | ||
299 | command.Parameters.Add(database.CreateParameter("uuid", uuid)); | ||
300 | try | ||
301 | { | ||
302 | using (SqlDataReader reader = command.ExecuteReader()) | ||
303 | { | ||
304 | return readAgentRow(reader); | ||
305 | } | ||
306 | } | ||
307 | catch (Exception e) | ||
308 | { | ||
309 | m_log.ErrorFormat("[USER DB] Error updating agentdata by UUID, error: {0}", e.Message); | ||
310 | return null; | ||
311 | } | ||
312 | } | ||
313 | } | ||
314 | |||
315 | /// <summary> | ||
316 | /// Creates a new agent | ||
317 | /// </summary> | ||
318 | /// <param name="agent">The agent to create</param> | ||
319 | override public void AddNewUserAgent(UserAgentData agent) | ||
320 | { | ||
321 | try | ||
322 | { | ||
323 | InsertUpdateAgentRow(agent); | ||
324 | } | ||
325 | catch (Exception e) | ||
326 | { | ||
327 | m_log.ErrorFormat("[USER DB] Error adding new agentdata, error: {0}", e.Message); | ||
328 | } | ||
329 | } | ||
330 | |||
331 | #endregion | ||
332 | |||
333 | #region User Friends List Data | ||
334 | |||
335 | /// <summary> | ||
336 | /// Add a new friend in the friendlist | ||
337 | /// </summary> | ||
338 | /// <param name="friendlistowner">UUID of the friendlist owner</param> | ||
339 | /// <param name="friend">Friend's UUID</param> | ||
340 | /// <param name="perms">Permission flag</param> | ||
341 | override public void AddNewUserFriend(UUID friendlistowner, UUID friend, uint perms) | ||
342 | { | ||
343 | int dtvalue = Util.UnixTimeSinceEpoch(); | ||
344 | string sql = string.Format(@"INSERT INTO {0} | ||
345 | (ownerID,friendID,friendPerms,datetimestamp) | ||
346 | VALUES | ||
347 | (@ownerID,@friendID,@friendPerms,@datetimestamp)", m_userFriendsTableName); | ||
348 | using (AutoClosingSqlCommand command = database.Query(sql)) | ||
349 | { | ||
350 | command.Parameters.Add(database.CreateParameter("ownerID", friendlistowner)); | ||
351 | command.Parameters.Add(database.CreateParameter("friendID", friend)); | ||
352 | command.Parameters.Add(database.CreateParameter("friendPerms", perms)); | ||
353 | command.Parameters.Add(database.CreateParameter("datetimestamp", dtvalue)); | ||
354 | command.ExecuteNonQuery(); | ||
355 | |||
356 | try | ||
357 | { | ||
358 | sql = string.Format(@"INSERT INTO {0} | ||
359 | (ownerID,friendID,friendPerms,datetimestamp) | ||
360 | VALUES | ||
361 | (@friendID,@ownerID,@friendPerms,@datetimestamp)", m_userFriendsTableName); | ||
362 | command.CommandText = sql; | ||
363 | command.ExecuteNonQuery(); | ||
364 | } | ||
365 | catch (Exception e) | ||
366 | { | ||
367 | m_log.ErrorFormat("[USER DB] Error adding new userfriend, error: {0}", e.Message); | ||
368 | return; | ||
369 | } | ||
370 | } | ||
371 | } | ||
372 | |||
373 | /// <summary> | ||
374 | /// Remove an friend from the friendlist | ||
375 | /// </summary> | ||
376 | /// <param name="friendlistowner">UUID of the friendlist owner</param> | ||
377 | /// <param name="friend">UUID of the not-so-friendly user to remove from the list</param> | ||
378 | override public void RemoveUserFriend(UUID friendlistowner, UUID friend) | ||
379 | { | ||
380 | string sql = string.Format(@"DELETE from {0} | ||
381 | WHERE ownerID = @ownerID | ||
382 | AND friendID = @friendID", m_userFriendsTableName); | ||
383 | using (AutoClosingSqlCommand command = database.Query(sql)) | ||
384 | { | ||
385 | command.Parameters.Add(database.CreateParameter("@ownerID", friendlistowner)); | ||
386 | command.Parameters.Add(database.CreateParameter("@friendID", friend)); | ||
387 | command.ExecuteNonQuery(); | ||
388 | sql = string.Format(@"DELETE from {0} | ||
389 | WHERE ownerID = @friendID | ||
390 | AND friendID = @ownerID", m_userFriendsTableName); | ||
391 | command.CommandText = sql; | ||
392 | try | ||
393 | { | ||
394 | command.ExecuteNonQuery(); | ||
395 | } | ||
396 | catch (Exception e) | ||
397 | { | ||
398 | m_log.ErrorFormat("[USER DB] Error removing userfriend, error: {0}", e.Message); | ||
399 | } | ||
400 | } | ||
401 | } | ||
402 | |||
403 | /// <summary> | ||
404 | /// Update friendlist permission flag for a friend | ||
405 | /// </summary> | ||
406 | /// <param name="friendlistowner">UUID of the friendlist owner</param> | ||
407 | /// <param name="friend">UUID of the friend</param> | ||
408 | /// <param name="perms">new permission flag</param> | ||
409 | override public void UpdateUserFriendPerms(UUID friendlistowner, UUID friend, uint perms) | ||
410 | { | ||
411 | string sql = string.Format(@"UPDATE {0} SET friendPerms = @friendPerms | ||
412 | WHERE ownerID = @ownerID | ||
413 | AND friendID = @friendID", m_userFriendsTableName); | ||
414 | using (AutoClosingSqlCommand command = database.Query(sql)) | ||
415 | { | ||
416 | command.Parameters.Add(database.CreateParameter("@ownerID", friendlistowner)); | ||
417 | command.Parameters.Add(database.CreateParameter("@friendID", friend)); | ||
418 | command.Parameters.Add(database.CreateParameter("@friendPerms", perms)); | ||
419 | |||
420 | try | ||
421 | { | ||
422 | command.ExecuteNonQuery(); | ||
423 | } | ||
424 | catch (Exception e) | ||
425 | { | ||
426 | m_log.ErrorFormat("[USER DB] Error updating userfriend, error: {0}", e.Message); | ||
427 | } | ||
428 | } | ||
429 | } | ||
430 | |||
431 | /// <summary> | ||
432 | /// Get (fetch?) the user's friendlist | ||
433 | /// </summary> | ||
434 | /// <param name="friendlistowner">UUID of the friendlist owner</param> | ||
435 | /// <returns>Friendlist list</returns> | ||
436 | override public List<FriendListItem> GetUserFriendList(UUID friendlistowner) | ||
437 | { | ||
438 | List<FriendListItem> friendList = new List<FriendListItem>(); | ||
439 | |||
440 | //Left Join userfriends to itself | ||
441 | string sql = string.Format(@"SELECT a.ownerID, a.friendID, a.friendPerms, b.friendPerms AS ownerperms | ||
442 | FROM {0} as a, {0} as b | ||
443 | WHERE a.ownerID = @ownerID | ||
444 | AND b.ownerID = a.friendID | ||
445 | AND b.friendID = a.ownerID", m_userFriendsTableName); | ||
446 | using (AutoClosingSqlCommand command = database.Query(sql)) | ||
447 | { | ||
448 | command.Parameters.Add(database.CreateParameter("@ownerID", friendlistowner)); | ||
449 | try | ||
450 | { | ||
451 | using (SqlDataReader reader = command.ExecuteReader()) | ||
452 | { | ||
453 | while (reader.Read()) | ||
454 | { | ||
455 | FriendListItem fli = new FriendListItem(); | ||
456 | fli.FriendListOwner = new UUID((Guid)reader["ownerID"]); | ||
457 | fli.Friend = new UUID((Guid)reader["friendID"]); | ||
458 | fli.FriendPerms = (uint)Convert.ToInt32(reader["friendPerms"]); | ||
459 | |||
460 | // This is not a real column in the database table, it's a joined column from the opposite record | ||
461 | fli.FriendListOwnerPerms = (uint)Convert.ToInt32(reader["ownerperms"]); | ||
462 | friendList.Add(fli); | ||
463 | } | ||
464 | } | ||
465 | } | ||
466 | catch (Exception e) | ||
467 | { | ||
468 | m_log.ErrorFormat("[USER DB] Error updating userfriend, error: {0}", e.Message); | ||
469 | } | ||
470 | } | ||
471 | return friendList; | ||
472 | } | ||
473 | |||
474 | override public Dictionary<UUID, FriendRegionInfo> GetFriendRegionInfos (List<UUID> uuids) | ||
475 | { | ||
476 | Dictionary<UUID, FriendRegionInfo> infos = new Dictionary<UUID,FriendRegionInfo>(); | ||
477 | try | ||
478 | { | ||
479 | foreach (UUID uuid in uuids) | ||
480 | { | ||
481 | string sql = string.Format(@"SELECT agentOnline,currentHandle | ||
482 | FROM {0} WHERE UUID = @uuid", m_agentsTableName); | ||
483 | using (AutoClosingSqlCommand command = database.Query(sql)) | ||
484 | { | ||
485 | command.Parameters.Add(database.CreateParameter("@uuid", uuid)); | ||
486 | using (SqlDataReader reader = command.ExecuteReader()) | ||
487 | { | ||
488 | while (reader.Read()) | ||
489 | { | ||
490 | FriendRegionInfo fri = new FriendRegionInfo(); | ||
491 | fri.isOnline = (byte)reader["agentOnline"] != 0; | ||
492 | fri.regionHandle = Convert.ToUInt64(reader["currentHandle"].ToString()); | ||
493 | |||
494 | infos[uuid] = fri; | ||
495 | } | ||
496 | } | ||
497 | } | ||
498 | } | ||
499 | } | ||
500 | catch (Exception e) | ||
501 | { | ||
502 | m_log.Warn("[MSSQL]: Got exception on trying to find friends regions:", e); | ||
503 | } | ||
504 | |||
505 | return infos; | ||
506 | } | ||
507 | #endregion | ||
508 | |||
509 | #region Money functions (not used) | ||
510 | |||
511 | /// <summary> | ||
512 | /// Performs a money transfer request between two accounts | ||
513 | /// </summary> | ||
514 | /// <param name="from">The senders account ID</param> | ||
515 | /// <param name="to">The receivers account ID</param> | ||
516 | /// <param name="amount">The amount to transfer</param> | ||
517 | /// <returns>false</returns> | ||
518 | override public bool MoneyTransferRequest(UUID from, UUID to, uint amount) | ||
519 | { | ||
520 | return false; | ||
521 | } | ||
522 | |||
523 | /// <summary> | ||
524 | /// Performs an inventory transfer request between two accounts | ||
525 | /// </summary> | ||
526 | /// <remarks>TODO: Move to inventory server</remarks> | ||
527 | /// <param name="from">The senders account ID</param> | ||
528 | /// <param name="to">The receivers account ID</param> | ||
529 | /// <param name="item">The item to transfer</param> | ||
530 | /// <returns>false</returns> | ||
531 | override public bool InventoryTransferRequest(UUID from, UUID to, UUID item) | ||
532 | { | ||
533 | return false; | ||
534 | } | ||
535 | |||
536 | #endregion | ||
537 | |||
538 | #region Appearance methods | ||
539 | |||
540 | /// <summary> | ||
541 | /// Gets the user appearance. | ||
542 | /// </summary> | ||
543 | /// <param name="user">The user.</param> | ||
544 | /// <returns></returns> | ||
545 | override public AvatarAppearance GetUserAppearance(UUID user) | ||
546 | { | ||
547 | try | ||
548 | { | ||
549 | AvatarAppearance appearance = new AvatarAppearance(); | ||
550 | string sql = "SELECT * FROM avatarappearance WHERE owner = @UUID"; | ||
551 | using (AutoClosingSqlCommand command = database.Query(sql)) | ||
552 | { | ||
553 | command.Parameters.Add(database.CreateParameter("@UUID", user)); | ||
554 | using (SqlDataReader reader = command.ExecuteReader()) | ||
555 | { | ||
556 | if (reader.Read()) | ||
557 | appearance = readUserAppearance(reader); | ||
558 | else | ||
559 | { | ||
560 | m_log.WarnFormat("[USER DB] No appearance found for user {0}", user.ToString()); | ||
561 | return null; | ||
562 | } | ||
563 | |||
564 | } | ||
565 | } | ||
566 | |||
567 | appearance.SetAttachments(GetUserAttachments(user)); | ||
568 | |||
569 | return appearance; | ||
570 | } | ||
571 | catch (Exception e) | ||
572 | { | ||
573 | m_log.ErrorFormat("[USER DB] Error updating userfriend, error: {0}", e.Message); | ||
574 | } | ||
575 | return null; | ||
576 | } | ||
577 | |||
578 | /// <summary> | ||
579 | /// Update a user appearence into database | ||
580 | /// </summary> | ||
581 | /// <param name="user">the used UUID</param> | ||
582 | /// <param name="appearance">the appearence</param> | ||
583 | override public void UpdateUserAppearance(UUID user, AvatarAppearance appearance) | ||
584 | { | ||
585 | string sql = @"DELETE FROM avatarappearance WHERE owner=@owner; | ||
586 | INSERT INTO avatarappearance | ||
587 | (owner, serial, visual_params, texture, avatar_height, | ||
588 | body_item, body_asset, skin_item, skin_asset, hair_item, | ||
589 | hair_asset, eyes_item, eyes_asset, shirt_item, shirt_asset, | ||
590 | pants_item, pants_asset, shoes_item, shoes_asset, socks_item, | ||
591 | socks_asset, jacket_item, jacket_asset, gloves_item, gloves_asset, | ||
592 | undershirt_item, undershirt_asset, underpants_item, underpants_asset, | ||
593 | skirt_item, skirt_asset) | ||
594 | VALUES | ||
595 | (@owner, @serial, @visual_params, @texture, @avatar_height, | ||
596 | @body_item, @body_asset, @skin_item, @skin_asset, @hair_item, | ||
597 | @hair_asset, @eyes_item, @eyes_asset, @shirt_item, @shirt_asset, | ||
598 | @pants_item, @pants_asset, @shoes_item, @shoes_asset, @socks_item, | ||
599 | @socks_asset, @jacket_item, @jacket_asset, @gloves_item, @gloves_asset, | ||
600 | @undershirt_item, @undershirt_asset, @underpants_item, @underpants_asset, | ||
601 | @skirt_item, @skirt_asset)"; | ||
602 | |||
603 | using (AutoClosingSqlCommand cmd = database.Query(sql)) | ||
604 | { | ||
605 | cmd.Parameters.Add(database.CreateParameter("@owner", appearance.Owner)); | ||
606 | cmd.Parameters.Add(database.CreateParameter("@serial", appearance.Serial)); | ||
607 | cmd.Parameters.Add(database.CreateParameter("@visual_params", appearance.VisualParams)); | ||
608 | cmd.Parameters.Add(database.CreateParameter("@texture", appearance.Texture.GetBytes())); | ||
609 | cmd.Parameters.Add(database.CreateParameter("@avatar_height", appearance.AvatarHeight)); | ||
610 | cmd.Parameters.Add(database.CreateParameter("@body_item", appearance.BodyItem)); | ||
611 | cmd.Parameters.Add(database.CreateParameter("@body_asset", appearance.BodyAsset)); | ||
612 | cmd.Parameters.Add(database.CreateParameter("@skin_item", appearance.SkinItem)); | ||
613 | cmd.Parameters.Add(database.CreateParameter("@skin_asset", appearance.SkinAsset)); | ||
614 | cmd.Parameters.Add(database.CreateParameter("@hair_item", appearance.HairItem)); | ||
615 | cmd.Parameters.Add(database.CreateParameter("@hair_asset", appearance.HairAsset)); | ||
616 | cmd.Parameters.Add(database.CreateParameter("@eyes_item", appearance.EyesItem)); | ||
617 | cmd.Parameters.Add(database.CreateParameter("@eyes_asset", appearance.EyesAsset)); | ||
618 | cmd.Parameters.Add(database.CreateParameter("@shirt_item", appearance.ShirtItem)); | ||
619 | cmd.Parameters.Add(database.CreateParameter("@shirt_asset", appearance.ShirtAsset)); | ||
620 | cmd.Parameters.Add(database.CreateParameter("@pants_item", appearance.PantsItem)); | ||
621 | cmd.Parameters.Add(database.CreateParameter("@pants_asset", appearance.PantsAsset)); | ||
622 | cmd.Parameters.Add(database.CreateParameter("@shoes_item", appearance.ShoesItem)); | ||
623 | cmd.Parameters.Add(database.CreateParameter("@shoes_asset", appearance.ShoesAsset)); | ||
624 | cmd.Parameters.Add(database.CreateParameter("@socks_item", appearance.SocksItem)); | ||
625 | cmd.Parameters.Add(database.CreateParameter("@socks_asset", appearance.SocksAsset)); | ||
626 | cmd.Parameters.Add(database.CreateParameter("@jacket_item", appearance.JacketItem)); | ||
627 | cmd.Parameters.Add(database.CreateParameter("@jacket_asset", appearance.JacketAsset)); | ||
628 | cmd.Parameters.Add(database.CreateParameter("@gloves_item", appearance.GlovesItem)); | ||
629 | cmd.Parameters.Add(database.CreateParameter("@gloves_asset", appearance.GlovesAsset)); | ||
630 | cmd.Parameters.Add(database.CreateParameter("@undershirt_item", appearance.UnderShirtItem)); | ||
631 | cmd.Parameters.Add(database.CreateParameter("@undershirt_asset", appearance.UnderShirtAsset)); | ||
632 | cmd.Parameters.Add(database.CreateParameter("@underpants_item", appearance.UnderPantsItem)); | ||
633 | cmd.Parameters.Add(database.CreateParameter("@underpants_asset", appearance.UnderPantsAsset)); | ||
634 | cmd.Parameters.Add(database.CreateParameter("@skirt_item", appearance.SkirtItem)); | ||
635 | cmd.Parameters.Add(database.CreateParameter("@skirt_asset", appearance.SkirtAsset)); | ||
636 | |||
637 | try | ||
638 | { | ||
639 | cmd.ExecuteNonQuery(); | ||
640 | } | ||
641 | catch (Exception e) | ||
642 | { | ||
643 | m_log.ErrorFormat("[USER DB] Error updating user appearance, error: {0}", e.Message); | ||
644 | } | ||
645 | } | ||
646 | UpdateUserAttachments(user, appearance.GetAttachments()); | ||
647 | } | ||
648 | |||
649 | #endregion | ||
650 | |||
651 | #region Attachment methods | ||
652 | |||
653 | /// <summary> | ||
654 | /// Gets all attachment of a agent. | ||
655 | /// </summary> | ||
656 | /// <param name="agentID">agent ID.</param> | ||
657 | /// <returns></returns> | ||
658 | public Hashtable GetUserAttachments(UUID agentID) | ||
659 | { | ||
660 | Hashtable returnTable = new Hashtable(); | ||
661 | string sql = "select attachpoint, item, asset from avatarattachments where UUID = @uuid"; | ||
662 | using (AutoClosingSqlCommand command = database.Query(sql, database.CreateParameter("@uuid", agentID))) | ||
663 | { | ||
664 | using (SqlDataReader reader = command.ExecuteReader()) | ||
665 | { | ||
666 | while (reader.Read()) | ||
667 | { | ||
668 | int attachpoint = Convert.ToInt32(reader["attachpoint"]); | ||
669 | if (returnTable.ContainsKey(attachpoint)) | ||
670 | continue; | ||
671 | Hashtable item = new Hashtable(); | ||
672 | item.Add("item", reader["item"].ToString()); | ||
673 | item.Add("asset", reader["asset"].ToString()); | ||
674 | |||
675 | returnTable.Add(attachpoint, item); | ||
676 | } | ||
677 | } | ||
678 | } | ||
679 | return returnTable; | ||
680 | } | ||
681 | |||
682 | /// <summary> | ||
683 | /// Updates all attachments of the agent. | ||
684 | /// </summary> | ||
685 | /// <param name="agentID">agentID.</param> | ||
686 | /// <param name="data">data with all items on attachmentpoints</param> | ||
687 | public void UpdateUserAttachments(UUID agentID, Hashtable data) | ||
688 | { | ||
689 | string sql = "DELETE FROM avatarattachments WHERE UUID = @uuid"; | ||
690 | |||
691 | using (AutoClosingSqlCommand command = database.Query(sql)) | ||
692 | { | ||
693 | command.Parameters.Add(database.CreateParameter("uuid", agentID)); | ||
694 | command.ExecuteNonQuery(); | ||
695 | } | ||
696 | if (data == null) | ||
697 | return; | ||
698 | |||
699 | sql = @"INSERT INTO avatarattachments (UUID, attachpoint, item, asset) | ||
700 | VALUES (@uuid, @attachpoint, @item, @asset)"; | ||
701 | |||
702 | using (AutoClosingSqlCommand command = database.Query(sql)) | ||
703 | { | ||
704 | bool firstTime = true; | ||
705 | foreach (DictionaryEntry e in data) | ||
706 | { | ||
707 | int attachpoint = Convert.ToInt32(e.Key); | ||
708 | |||
709 | Hashtable item = (Hashtable)e.Value; | ||
710 | |||
711 | if (firstTime) | ||
712 | { | ||
713 | command.Parameters.Add(database.CreateParameter("@uuid", agentID)); | ||
714 | command.Parameters.Add(database.CreateParameter("@attachpoint", attachpoint)); | ||
715 | command.Parameters.Add(database.CreateParameter("@item", new UUID(item["item"].ToString()))); | ||
716 | command.Parameters.Add(database.CreateParameter("@asset", new UUID(item["asset"].ToString()))); | ||
717 | firstTime = false; | ||
718 | } | ||
719 | command.Parameters["@uuid"].Value = agentID.Guid; //.ToString(); | ||
720 | command.Parameters["@attachpoint"].Value = attachpoint; | ||
721 | command.Parameters["@item"].Value = new Guid(item["item"].ToString()); | ||
722 | command.Parameters["@asset"].Value = new Guid(item["asset"].ToString()); | ||
723 | |||
724 | try | ||
725 | { | ||
726 | command.ExecuteNonQuery(); | ||
727 | } | ||
728 | catch (Exception ex) | ||
729 | { | ||
730 | m_log.DebugFormat("[USER DB] : Error adding user attachment. {0}", ex.Message); | ||
731 | } | ||
732 | } | ||
733 | } | ||
734 | } | ||
735 | |||
736 | /// <summary> | ||
737 | /// Resets all attachments of a agent in the database. | ||
738 | /// </summary> | ||
739 | /// <param name="agentID">agentID.</param> | ||
740 | override public void ResetAttachments(UUID agentID) | ||
741 | { | ||
742 | string sql = "UPDATE avatarattachments SET asset = '00000000-0000-0000-0000-000000000000' WHERE UUID = @uuid"; | ||
743 | using (AutoClosingSqlCommand command = database.Query(sql)) | ||
744 | { | ||
745 | command.Parameters.Add(database.CreateParameter("uuid", agentID)); | ||
746 | command.ExecuteNonQuery(); | ||
747 | } | ||
748 | } | ||
749 | |||
750 | override public void LogoutUsers(UUID regionID) | ||
751 | { | ||
752 | } | ||
753 | |||
754 | #endregion | ||
755 | |||
756 | #region Other public methods | ||
757 | |||
758 | /// <summary> | ||
759 | /// | ||
760 | /// </summary> | ||
761 | /// <param name="queryID"></param> | ||
762 | /// <param name="query"></param> | ||
763 | /// <returns></returns> | ||
764 | override public List<AvatarPickerAvatar> GeneratePickerResults(UUID queryID, string query) | ||
765 | { | ||
766 | List<AvatarPickerAvatar> returnlist = new List<AvatarPickerAvatar>(); | ||
767 | string[] querysplit = query.Split(' '); | ||
768 | if (querysplit.Length == 2) | ||
769 | { | ||
770 | try | ||
771 | { | ||
772 | string sql = string.Format(@"SELECT UUID,username,lastname FROM {0} | ||
773 | WHERE username LIKE @first AND lastname LIKE @second", m_usersTableName); | ||
774 | using (AutoClosingSqlCommand command = database.Query(sql)) | ||
775 | { | ||
776 | //Add wildcard to the search | ||
777 | command.Parameters.Add(database.CreateParameter("first", querysplit[0] + "%")); | ||
778 | command.Parameters.Add(database.CreateParameter("second", querysplit[1] + "%")); | ||
779 | using (SqlDataReader reader = command.ExecuteReader()) | ||
780 | { | ||
781 | while (reader.Read()) | ||
782 | { | ||
783 | AvatarPickerAvatar user = new AvatarPickerAvatar(); | ||
784 | user.AvatarID = new UUID((Guid)reader["UUID"]); | ||
785 | user.firstName = (string)reader["username"]; | ||
786 | user.lastName = (string)reader["lastname"]; | ||
787 | returnlist.Add(user); | ||
788 | } | ||
789 | } | ||
790 | } | ||
791 | } | ||
792 | catch (Exception e) | ||
793 | { | ||
794 | m_log.Error(e.ToString()); | ||
795 | } | ||
796 | } | ||
797 | else if (querysplit.Length == 1) | ||
798 | { | ||
799 | try | ||
800 | { | ||
801 | string sql = string.Format(@"SELECT UUID,username,lastname FROM {0} | ||
802 | WHERE username LIKE @first OR lastname LIKE @first", m_usersTableName); | ||
803 | using (AutoClosingSqlCommand command = database.Query(sql)) | ||
804 | { | ||
805 | command.Parameters.Add(database.CreateParameter("first", querysplit[0] + "%")); | ||
806 | |||
807 | using (SqlDataReader reader = command.ExecuteReader()) | ||
808 | { | ||
809 | while (reader.Read()) | ||
810 | { | ||
811 | AvatarPickerAvatar user = new AvatarPickerAvatar(); | ||
812 | user.AvatarID = new UUID((Guid)reader["UUID"]); | ||
813 | user.firstName = (string)reader["username"]; | ||
814 | user.lastName = (string)reader["lastname"]; | ||
815 | returnlist.Add(user); | ||
816 | } | ||
817 | } | ||
818 | } | ||
819 | } | ||
820 | catch (Exception e) | ||
821 | { | ||
822 | m_log.Error(e.ToString()); | ||
823 | } | ||
824 | } | ||
825 | return returnlist; | ||
826 | } | ||
827 | |||
828 | /// <summary> | ||
829 | /// Store a weblogin key | ||
830 | /// </summary> | ||
831 | /// <param name="AgentID">The agent UUID</param> | ||
832 | /// <param name="WebLoginKey">the WebLogin Key</param> | ||
833 | /// <remarks>unused ?</remarks> | ||
834 | override public void StoreWebLoginKey(UUID AgentID, UUID WebLoginKey) | ||
835 | { | ||
836 | UserProfileData user = GetUserByUUID(AgentID); | ||
837 | user.WebLoginKey = WebLoginKey; | ||
838 | UpdateUserProfile(user); | ||
839 | } | ||
840 | |||
841 | /// <summary> | ||
842 | /// Database provider name | ||
843 | /// </summary> | ||
844 | /// <returns>Provider name</returns> | ||
845 | override public string Name | ||
846 | { | ||
847 | get { return "MSSQL Userdata Interface"; } | ||
848 | } | ||
849 | |||
850 | /// <summary> | ||
851 | /// Database provider version | ||
852 | /// </summary> | ||
853 | /// <returns>provider version</returns> | ||
854 | override public string Version | ||
855 | { | ||
856 | get { return database.getVersion(); } | ||
857 | } | ||
858 | |||
859 | #endregion | ||
860 | |||
861 | #region Private functions | ||
862 | |||
863 | /// <summary> | ||
864 | /// Reads a one item from an SQL result | ||
865 | /// </summary> | ||
866 | /// <param name="reader">The SQL Result</param> | ||
867 | /// <returns>the item read</returns> | ||
868 | private static AvatarAppearance readUserAppearance(SqlDataReader reader) | ||
869 | { | ||
870 | try | ||
871 | { | ||
872 | AvatarAppearance appearance = new AvatarAppearance(); | ||
873 | |||
874 | appearance.Owner = new UUID((Guid)reader["owner"]); | ||
875 | appearance.Serial = Convert.ToInt32(reader["serial"]); | ||
876 | appearance.VisualParams = (byte[])reader["visual_params"]; | ||
877 | appearance.Texture = new Primitive.TextureEntry((byte[])reader["texture"], 0, ((byte[])reader["texture"]).Length); | ||
878 | appearance.AvatarHeight = (float)Convert.ToDouble(reader["avatar_height"]); | ||
879 | appearance.BodyItem = new UUID((Guid)reader["body_item"]); | ||
880 | appearance.BodyAsset = new UUID((Guid)reader["body_asset"]); | ||
881 | appearance.SkinItem = new UUID((Guid)reader["skin_item"]); | ||
882 | appearance.SkinAsset = new UUID((Guid)reader["skin_asset"]); | ||
883 | appearance.HairItem = new UUID((Guid)reader["hair_item"]); | ||
884 | appearance.HairAsset = new UUID((Guid)reader["hair_asset"]); | ||
885 | appearance.EyesItem = new UUID((Guid)reader["eyes_item"]); | ||
886 | appearance.EyesAsset = new UUID((Guid)reader["eyes_asset"]); | ||
887 | appearance.ShirtItem = new UUID((Guid)reader["shirt_item"]); | ||
888 | appearance.ShirtAsset = new UUID((Guid)reader["shirt_asset"]); | ||
889 | appearance.PantsItem = new UUID((Guid)reader["pants_item"]); | ||
890 | appearance.PantsAsset = new UUID((Guid)reader["pants_asset"]); | ||
891 | appearance.ShoesItem = new UUID((Guid)reader["shoes_item"]); | ||
892 | appearance.ShoesAsset = new UUID((Guid)reader["shoes_asset"]); | ||
893 | appearance.SocksItem = new UUID((Guid)reader["socks_item"]); | ||
894 | appearance.SocksAsset = new UUID((Guid)reader["socks_asset"]); | ||
895 | appearance.JacketItem = new UUID((Guid)reader["jacket_item"]); | ||
896 | appearance.JacketAsset = new UUID((Guid)reader["jacket_asset"]); | ||
897 | appearance.GlovesItem = new UUID((Guid)reader["gloves_item"]); | ||
898 | appearance.GlovesAsset = new UUID((Guid)reader["gloves_asset"]); | ||
899 | appearance.UnderShirtItem = new UUID((Guid)reader["undershirt_item"]); | ||
900 | appearance.UnderShirtAsset = new UUID((Guid)reader["undershirt_asset"]); | ||
901 | appearance.UnderPantsItem = new UUID((Guid)reader["underpants_item"]); | ||
902 | appearance.UnderPantsAsset = new UUID((Guid)reader["underpants_asset"]); | ||
903 | appearance.SkirtItem = new UUID((Guid)reader["skirt_item"]); | ||
904 | appearance.SkirtAsset = new UUID((Guid)reader["skirt_asset"]); | ||
905 | |||
906 | return appearance; | ||
907 | } | ||
908 | catch (SqlException e) | ||
909 | { | ||
910 | m_log.Error(e.ToString()); | ||
911 | } | ||
912 | |||
913 | return null; | ||
914 | } | ||
915 | |||
916 | /// <summary> | ||
917 | /// Insert/Update a agent row in the DB. | ||
918 | /// </summary> | ||
919 | /// <param name="agentdata">agentdata.</param> | ||
920 | private void InsertUpdateAgentRow(UserAgentData agentdata) | ||
921 | { | ||
922 | string sql = @" | ||
923 | |||
924 | IF EXISTS (SELECT * FROM agents WHERE UUID = @UUID) | ||
925 | BEGIN | ||
926 | UPDATE agents SET UUID = @UUID, sessionID = @sessionID, secureSessionID = @secureSessionID, agentIP = @agentIP, agentPort = @agentPort, agentOnline = @agentOnline, loginTime = @loginTime, logoutTime = @logoutTime, currentRegion = @currentRegion, currentHandle = @currentHandle, currentPos = @currentPos | ||
927 | WHERE UUID = @UUID | ||
928 | END | ||
929 | ELSE | ||
930 | BEGIN | ||
931 | INSERT INTO | ||
932 | agents (UUID, sessionID, secureSessionID, agentIP, agentPort, agentOnline, loginTime, logoutTime, currentRegion, currentHandle, currentPos) VALUES | ||
933 | (@UUID, @sessionID, @secureSessionID, @agentIP, @agentPort, @agentOnline, @loginTime, @logoutTime, @currentRegion, @currentHandle, @currentPos) | ||
934 | END | ||
935 | "; | ||
936 | |||
937 | using (AutoClosingSqlCommand command = database.Query(sql)) | ||
938 | { | ||
939 | command.Parameters.Add(database.CreateParameter("@UUID", agentdata.ProfileID)); | ||
940 | command.Parameters.Add(database.CreateParameter("@sessionID", agentdata.SessionID)); | ||
941 | command.Parameters.Add(database.CreateParameter("@secureSessionID", agentdata.SecureSessionID)); | ||
942 | command.Parameters.Add(database.CreateParameter("@agentIP", agentdata.AgentIP)); | ||
943 | command.Parameters.Add(database.CreateParameter("@agentPort", agentdata.AgentPort)); | ||
944 | command.Parameters.Add(database.CreateParameter("@agentOnline", agentdata.AgentOnline)); | ||
945 | command.Parameters.Add(database.CreateParameter("@loginTime", agentdata.LoginTime)); | ||
946 | command.Parameters.Add(database.CreateParameter("@logoutTime", agentdata.LogoutTime)); | ||
947 | command.Parameters.Add(database.CreateParameter("@currentRegion", agentdata.Region)); | ||
948 | command.Parameters.Add(database.CreateParameter("@currentHandle", agentdata.Handle)); | ||
949 | command.Parameters.Add(database.CreateParameter("@currentPos", "<" + ((int)agentdata.Position.X) + "," + ((int)agentdata.Position.Y) + "," + ((int)agentdata.Position.Z) + ">")); | ||
950 | |||
951 | command.Transaction = command.Connection.BeginTransaction(IsolationLevel.Serializable); | ||
952 | try | ||
953 | { | ||
954 | if (command.ExecuteNonQuery() > 0) | ||
955 | { | ||
956 | command.Transaction.Commit(); | ||
957 | return; | ||
958 | } | ||
959 | |||
960 | command.Transaction.Rollback(); | ||
961 | return; | ||
962 | } | ||
963 | catch (Exception e) | ||
964 | { | ||
965 | command.Transaction.Rollback(); | ||
966 | m_log.Error(e.ToString()); | ||
967 | return; | ||
968 | } | ||
969 | } | ||
970 | |||
971 | } | ||
972 | |||
973 | /// <summary> | ||
974 | /// Reads an agent row from a database reader | ||
975 | /// </summary> | ||
976 | /// <param name="reader">An active database reader</param> | ||
977 | /// <returns>A user session agent</returns> | ||
978 | private UserAgentData readAgentRow(SqlDataReader reader) | ||
979 | { | ||
980 | UserAgentData retval = new UserAgentData(); | ||
981 | |||
982 | if (reader.Read()) | ||
983 | { | ||
984 | // Agent IDs | ||
985 | retval.ProfileID = new UUID((Guid)reader["UUID"]); | ||
986 | retval.SessionID = new UUID((Guid)reader["sessionID"]); | ||
987 | retval.SecureSessionID = new UUID((Guid)reader["secureSessionID"]); | ||
988 | |||
989 | // Agent Who? | ||
990 | retval.AgentIP = (string)reader["agentIP"]; | ||
991 | retval.AgentPort = Convert.ToUInt32(reader["agentPort"].ToString()); | ||
992 | retval.AgentOnline = Convert.ToInt32(reader["agentOnline"].ToString()) != 0; | ||
993 | |||
994 | // Login/Logout times (UNIX Epoch) | ||
995 | retval.LoginTime = Convert.ToInt32(reader["loginTime"].ToString()); | ||
996 | retval.LogoutTime = Convert.ToInt32(reader["logoutTime"].ToString()); | ||
997 | |||
998 | // Current position | ||
999 | retval.Region = new UUID((Guid)reader["currentRegion"]); | ||
1000 | retval.Handle = Convert.ToUInt64(reader["currentHandle"].ToString()); | ||
1001 | Vector3 tmp_v; | ||
1002 | Vector3.TryParse((string)reader["currentPos"], out tmp_v); | ||
1003 | retval.Position = tmp_v; | ||
1004 | |||
1005 | } | ||
1006 | else | ||
1007 | { | ||
1008 | return null; | ||
1009 | } | ||
1010 | return retval; | ||
1011 | } | ||
1012 | |||
1013 | /// <summary> | ||
1014 | /// Creates a new user and inserts it into the database | ||
1015 | /// </summary> | ||
1016 | /// <param name="uuid">User ID</param> | ||
1017 | /// <param name="username">First part of the login</param> | ||
1018 | /// <param name="lastname">Second part of the login</param> | ||
1019 | /// <param name="email">Email of person</param> | ||
1020 | /// <param name="passwordHash">A salted hash of the users password</param> | ||
1021 | /// <param name="passwordSalt">The salt used for the password hash</param> | ||
1022 | /// <param name="homeRegion">A regionHandle of the users home region</param> | ||
1023 | /// <param name="homeLocX">Home region position vector</param> | ||
1024 | /// <param name="homeLocY">Home region position vector</param> | ||
1025 | /// <param name="homeLocZ">Home region position vector</param> | ||
1026 | /// <param name="homeLookAtX">Home region 'look at' vector</param> | ||
1027 | /// <param name="homeLookAtY">Home region 'look at' vector</param> | ||
1028 | /// <param name="homeLookAtZ">Home region 'look at' vector</param> | ||
1029 | /// <param name="created">Account created (unix timestamp)</param> | ||
1030 | /// <param name="lastlogin">Last login (unix timestamp)</param> | ||
1031 | /// <param name="inventoryURI">Users inventory URI</param> | ||
1032 | /// <param name="assetURI">Users asset URI</param> | ||
1033 | /// <param name="canDoMask">I can do mask</param> | ||
1034 | /// <param name="wantDoMask">I want to do mask</param> | ||
1035 | /// <param name="aboutText">Profile text</param> | ||
1036 | /// <param name="firstText">Firstlife text</param> | ||
1037 | /// <param name="profileImage">UUID for profile image</param> | ||
1038 | /// <param name="firstImage">UUID for firstlife image</param> | ||
1039 | /// <param name="webLoginKey">web login key</param> | ||
1040 | /// <param name="homeRegionID">homeregion UUID</param> | ||
1041 | /// <param name="godLevel">has the user godlevel</param> | ||
1042 | /// <param name="userFlags">unknown</param> | ||
1043 | /// <param name="customType">unknown</param> | ||
1044 | /// <param name="partnerID">UUID of partner</param> | ||
1045 | /// <returns>Success?</returns> | ||
1046 | private void InsertUserRow(UUID uuid, string username, string lastname, string email, string passwordHash, | ||
1047 | string passwordSalt, UInt64 homeRegion, float homeLocX, float homeLocY, float homeLocZ, | ||
1048 | float homeLookAtX, float homeLookAtY, float homeLookAtZ, int created, int lastlogin, | ||
1049 | string inventoryURI, string assetURI, uint canDoMask, uint wantDoMask, | ||
1050 | string aboutText, string firstText, | ||
1051 | UUID profileImage, UUID firstImage, UUID webLoginKey, UUID homeRegionID, | ||
1052 | int godLevel, int userFlags, string customType, UUID partnerID) | ||
1053 | { | ||
1054 | string sql = string.Format(@"INSERT INTO {0} | ||
1055 | ([UUID], [username], [lastname], [email], [passwordHash], [passwordSalt], | ||
1056 | [homeRegion], [homeLocationX], [homeLocationY], [homeLocationZ], [homeLookAtX], | ||
1057 | [homeLookAtY], [homeLookAtZ], [created], [lastLogin], [userInventoryURI], | ||
1058 | [userAssetURI], [profileCanDoMask], [profileWantDoMask], [profileAboutText], | ||
1059 | [profileFirstText], [profileImage], [profileFirstImage], [webLoginKey], | ||
1060 | [homeRegionID], [userFlags], [godLevel], [customType], [partner]) | ||
1061 | VALUES | ||
1062 | (@UUID, @username, @lastname, @email, @passwordHash, @passwordSalt, | ||
1063 | @homeRegion, @homeLocationX, @homeLocationY, @homeLocationZ, @homeLookAtX, | ||
1064 | @homeLookAtY, @homeLookAtZ, @created, @lastLogin, @userInventoryURI, | ||
1065 | @userAssetURI, @profileCanDoMask, @profileWantDoMask, @profileAboutText, | ||
1066 | @profileFirstText, @profileImage, @profileFirstImage, @webLoginKey, | ||
1067 | @homeRegionID, @userFlags, @godLevel, @customType, @partner)", m_usersTableName); | ||
1068 | |||
1069 | try | ||
1070 | { | ||
1071 | using (AutoClosingSqlCommand command = database.Query(sql)) | ||
1072 | { | ||
1073 | command.Parameters.Add(database.CreateParameter("UUID", uuid)); | ||
1074 | command.Parameters.Add(database.CreateParameter("username", username)); | ||
1075 | command.Parameters.Add(database.CreateParameter("lastname", lastname)); | ||
1076 | command.Parameters.Add(database.CreateParameter("email", email)); | ||
1077 | command.Parameters.Add(database.CreateParameter("passwordHash", passwordHash)); | ||
1078 | command.Parameters.Add(database.CreateParameter("passwordSalt", passwordSalt)); | ||
1079 | command.Parameters.Add(database.CreateParameter("homeRegion", homeRegion)); | ||
1080 | command.Parameters.Add(database.CreateParameter("homeLocationX", homeLocX)); | ||
1081 | command.Parameters.Add(database.CreateParameter("homeLocationY", homeLocY)); | ||
1082 | command.Parameters.Add(database.CreateParameter("homeLocationZ", homeLocZ)); | ||
1083 | command.Parameters.Add(database.CreateParameter("homeLookAtX", homeLookAtX)); | ||
1084 | command.Parameters.Add(database.CreateParameter("homeLookAtY", homeLookAtY)); | ||
1085 | command.Parameters.Add(database.CreateParameter("homeLookAtZ", homeLookAtZ)); | ||
1086 | command.Parameters.Add(database.CreateParameter("created", created)); | ||
1087 | command.Parameters.Add(database.CreateParameter("lastLogin", lastlogin)); | ||
1088 | command.Parameters.Add(database.CreateParameter("userInventoryURI", inventoryURI)); | ||
1089 | command.Parameters.Add(database.CreateParameter("userAssetURI", assetURI)); | ||
1090 | command.Parameters.Add(database.CreateParameter("profileCanDoMask", canDoMask)); | ||
1091 | command.Parameters.Add(database.CreateParameter("profileWantDoMask", wantDoMask)); | ||
1092 | command.Parameters.Add(database.CreateParameter("profileAboutText", aboutText)); | ||
1093 | command.Parameters.Add(database.CreateParameter("profileFirstText", firstText)); | ||
1094 | command.Parameters.Add(database.CreateParameter("profileImage", profileImage)); | ||
1095 | command.Parameters.Add(database.CreateParameter("profileFirstImage", firstImage)); | ||
1096 | command.Parameters.Add(database.CreateParameter("webLoginKey", webLoginKey)); | ||
1097 | command.Parameters.Add(database.CreateParameter("homeRegionID", homeRegionID)); | ||
1098 | command.Parameters.Add(database.CreateParameter("userFlags", userFlags)); | ||
1099 | command.Parameters.Add(database.CreateParameter("godLevel", godLevel)); | ||
1100 | command.Parameters.Add(database.CreateParameter("customType", customType)); | ||
1101 | command.Parameters.Add(database.CreateParameter("partner", partnerID)); | ||
1102 | |||
1103 | command.ExecuteNonQuery(); | ||
1104 | return; | ||
1105 | } | ||
1106 | } | ||
1107 | catch (Exception e) | ||
1108 | { | ||
1109 | m_log.Error(e.ToString()); | ||
1110 | return; | ||
1111 | } | ||
1112 | } | ||
1113 | |||
1114 | /// <summary> | ||
1115 | /// Reads a user profile from an active data reader | ||
1116 | /// </summary> | ||
1117 | /// <param name="reader">An active database reader</param> | ||
1118 | /// <returns>A user profile</returns> | ||
1119 | private static UserProfileData ReadUserRow(SqlDataReader reader) | ||
1120 | { | ||
1121 | UserProfileData retval = new UserProfileData(); | ||
1122 | |||
1123 | if (reader.Read()) | ||
1124 | { | ||
1125 | retval.ID = new UUID((Guid)reader["UUID"]); | ||
1126 | retval.FirstName = (string)reader["username"]; | ||
1127 | retval.SurName = (string)reader["lastname"]; | ||
1128 | if (reader.IsDBNull(reader.GetOrdinal("email"))) | ||
1129 | retval.Email = ""; | ||
1130 | else | ||
1131 | retval.Email = (string)reader["email"]; | ||
1132 | |||
1133 | retval.PasswordHash = (string)reader["passwordHash"]; | ||
1134 | retval.PasswordSalt = (string)reader["passwordSalt"]; | ||
1135 | |||
1136 | retval.HomeRegion = Convert.ToUInt64(reader["homeRegion"].ToString()); | ||
1137 | retval.HomeLocation = new Vector3( | ||
1138 | Convert.ToSingle(reader["homeLocationX"].ToString()), | ||
1139 | Convert.ToSingle(reader["homeLocationY"].ToString()), | ||
1140 | Convert.ToSingle(reader["homeLocationZ"].ToString())); | ||
1141 | retval.HomeLookAt = new Vector3( | ||
1142 | Convert.ToSingle(reader["homeLookAtX"].ToString()), | ||
1143 | Convert.ToSingle(reader["homeLookAtY"].ToString()), | ||
1144 | Convert.ToSingle(reader["homeLookAtZ"].ToString())); | ||
1145 | |||
1146 | if (reader.IsDBNull(reader.GetOrdinal("homeRegionID"))) | ||
1147 | retval.HomeRegionID = UUID.Zero; | ||
1148 | else | ||
1149 | retval.HomeRegionID = new UUID((Guid)reader["homeRegionID"]); | ||
1150 | |||
1151 | retval.Created = Convert.ToInt32(reader["created"].ToString()); | ||
1152 | retval.LastLogin = Convert.ToInt32(reader["lastLogin"].ToString()); | ||
1153 | |||
1154 | if (reader.IsDBNull(reader.GetOrdinal("userInventoryURI"))) | ||
1155 | retval.UserInventoryURI = ""; | ||
1156 | else | ||
1157 | retval.UserInventoryURI = (string)reader["userInventoryURI"]; | ||
1158 | |||
1159 | if (reader.IsDBNull(reader.GetOrdinal("userAssetURI"))) | ||
1160 | retval.UserAssetURI = ""; | ||
1161 | else | ||
1162 | retval.UserAssetURI = (string)reader["userAssetURI"]; | ||
1163 | |||
1164 | retval.CanDoMask = Convert.ToUInt32(reader["profileCanDoMask"].ToString()); | ||
1165 | retval.WantDoMask = Convert.ToUInt32(reader["profileWantDoMask"].ToString()); | ||
1166 | |||
1167 | |||
1168 | if (reader.IsDBNull(reader.GetOrdinal("profileAboutText"))) | ||
1169 | retval.AboutText = ""; | ||
1170 | else | ||
1171 | retval.AboutText = (string)reader["profileAboutText"]; | ||
1172 | |||
1173 | if (reader.IsDBNull(reader.GetOrdinal("profileFirstText"))) | ||
1174 | retval.FirstLifeAboutText = ""; | ||
1175 | else | ||
1176 | retval.FirstLifeAboutText = (string)reader["profileFirstText"]; | ||
1177 | |||
1178 | if (reader.IsDBNull(reader.GetOrdinal("profileImage"))) | ||
1179 | retval.Image = UUID.Zero; | ||
1180 | else | ||
1181 | retval.Image = new UUID((Guid)reader["profileImage"]); | ||
1182 | |||
1183 | if (reader.IsDBNull(reader.GetOrdinal("profileFirstImage"))) | ||
1184 | retval.Image = UUID.Zero; | ||
1185 | else | ||
1186 | retval.FirstLifeImage = new UUID((Guid)reader["profileFirstImage"]); | ||
1187 | |||
1188 | if (reader.IsDBNull(reader.GetOrdinal("webLoginKey"))) | ||
1189 | retval.WebLoginKey = UUID.Zero; | ||
1190 | else | ||
1191 | retval.WebLoginKey = new UUID((Guid)reader["webLoginKey"]); | ||
1192 | |||
1193 | retval.UserFlags = Convert.ToInt32(reader["userFlags"].ToString()); | ||
1194 | retval.GodLevel = Convert.ToInt32(reader["godLevel"].ToString()); | ||
1195 | if (reader.IsDBNull(reader.GetOrdinal("customType"))) | ||
1196 | retval.CustomType = ""; | ||
1197 | else | ||
1198 | retval.CustomType = reader["customType"].ToString(); | ||
1199 | |||
1200 | if (reader.IsDBNull(reader.GetOrdinal("partner"))) | ||
1201 | retval.Partner = UUID.Zero; | ||
1202 | else | ||
1203 | retval.Partner = new UUID((Guid)reader["partner"]); | ||
1204 | } | ||
1205 | else | ||
1206 | { | ||
1207 | return null; | ||
1208 | } | ||
1209 | return retval; | ||
1210 | } | ||
1211 | #endregion | ||
1212 | } | ||
1213 | |||
1214 | } | ||
diff --git a/OpenSim/Data/MySQL/MySQLGridData.cs b/OpenSim/Data/MySQL/MySQLGridData.cs deleted file mode 100644 index f4e7b85..0000000 --- a/OpenSim/Data/MySQL/MySQLGridData.cs +++ /dev/null | |||
@@ -1,422 +0,0 @@ | |||
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.Data; | ||
31 | using System.Reflection; | ||
32 | using System.Threading; | ||
33 | using log4net; | ||
34 | using MySql.Data.MySqlClient; | ||
35 | using OpenMetaverse; | ||
36 | using OpenSim.Framework; | ||
37 | |||
38 | namespace OpenSim.Data.MySQL | ||
39 | { | ||
40 | /// <summary> | ||
41 | /// A MySQL Interface for the Grid Server | ||
42 | /// </summary> | ||
43 | public class MySQLGridData : GridDataBase | ||
44 | { | ||
45 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
46 | |||
47 | private MySQLManager m_database; | ||
48 | private object m_dbLock = new object(); | ||
49 | private string m_connectionString; | ||
50 | |||
51 | override public void Initialise() | ||
52 | { | ||
53 | m_log.Info("[MySQLGridData]: " + Name + " cannot be default-initialized!"); | ||
54 | throw new PluginNotInitialisedException (Name); | ||
55 | } | ||
56 | |||
57 | /// <summary> | ||
58 | /// <para>Initialises Grid interface</para> | ||
59 | /// <para> | ||
60 | /// <list type="bullet"> | ||
61 | /// <item>Loads and initialises the MySQL storage plugin</item> | ||
62 | /// <item>Warns and uses the obsolete mysql_connection.ini if connect string is empty.</item> | ||
63 | /// <item>Check for migration</item> | ||
64 | /// </list> | ||
65 | /// </para> | ||
66 | /// </summary> | ||
67 | /// <param name="connect">connect string.</param> | ||
68 | override public void Initialise(string connect) | ||
69 | { | ||
70 | m_connectionString = connect; | ||
71 | m_database = new MySQLManager(connect); | ||
72 | |||
73 | // This actually does the roll forward assembly stuff | ||
74 | Assembly assem = GetType().Assembly; | ||
75 | |||
76 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | ||
77 | { | ||
78 | Migration m = new Migration(dbcon, assem, "GridStore"); | ||
79 | m.Update(); | ||
80 | } | ||
81 | } | ||
82 | |||
83 | /// <summary> | ||
84 | /// Shuts down the grid interface | ||
85 | /// </summary> | ||
86 | override public void Dispose() | ||
87 | { | ||
88 | } | ||
89 | |||
90 | /// <summary> | ||
91 | /// Returns the plugin name | ||
92 | /// </summary> | ||
93 | /// <returns>Plugin name</returns> | ||
94 | override public string Name | ||
95 | { | ||
96 | get { return "MySql OpenGridData"; } | ||
97 | } | ||
98 | |||
99 | /// <summary> | ||
100 | /// Returns the plugin version | ||
101 | /// </summary> | ||
102 | /// <returns>Plugin version</returns> | ||
103 | override public string Version | ||
104 | { | ||
105 | get { return "0.1"; } | ||
106 | } | ||
107 | |||
108 | /// <summary> | ||
109 | /// Returns all the specified region profiles within coordates -- coordinates are inclusive | ||
110 | /// </summary> | ||
111 | /// <param name="xmin">Minimum X coordinate</param> | ||
112 | /// <param name="ymin">Minimum Y coordinate</param> | ||
113 | /// <param name="xmax">Maximum X coordinate</param> | ||
114 | /// <param name="ymax">Maximum Y coordinate</param> | ||
115 | /// <returns>Array of sim profiles</returns> | ||
116 | override public RegionProfileData[] GetProfilesInRange(uint xmin, uint ymin, uint xmax, uint ymax) | ||
117 | { | ||
118 | try | ||
119 | { | ||
120 | Dictionary<string, object> param = new Dictionary<string, object>(); | ||
121 | param["?xmin"] = xmin.ToString(); | ||
122 | param["?ymin"] = ymin.ToString(); | ||
123 | param["?xmax"] = xmax.ToString(); | ||
124 | param["?ymax"] = ymax.ToString(); | ||
125 | |||
126 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | ||
127 | { | ||
128 | dbcon.Open(); | ||
129 | |||
130 | using (IDbCommand result = m_database.Query(dbcon, | ||
131 | "SELECT * FROM regions WHERE locX >= ?xmin AND locX <= ?xmax AND locY >= ?ymin AND locY <= ?ymax", | ||
132 | param)) | ||
133 | { | ||
134 | using (IDataReader reader = result.ExecuteReader()) | ||
135 | { | ||
136 | RegionProfileData row; | ||
137 | |||
138 | List<RegionProfileData> rows = new List<RegionProfileData>(); | ||
139 | |||
140 | while ((row = m_database.readSimRow(reader)) != null) | ||
141 | rows.Add(row); | ||
142 | |||
143 | return rows.ToArray(); | ||
144 | } | ||
145 | } | ||
146 | } | ||
147 | } | ||
148 | catch (Exception e) | ||
149 | { | ||
150 | m_log.Error(e.Message, e); | ||
151 | return null; | ||
152 | } | ||
153 | } | ||
154 | |||
155 | /// <summary> | ||
156 | /// Returns up to maxNum profiles of regions that have a name starting with namePrefix | ||
157 | /// </summary> | ||
158 | /// <param name="name">The name to match against</param> | ||
159 | /// <param name="maxNum">Maximum number of profiles to return</param> | ||
160 | /// <returns>A list of sim profiles</returns> | ||
161 | override public List<RegionProfileData> GetRegionsByName(string namePrefix, uint maxNum) | ||
162 | { | ||
163 | try | ||
164 | { | ||
165 | Dictionary<string, object> param = new Dictionary<string, object>(); | ||
166 | param["?name"] = namePrefix + "%"; | ||
167 | |||
168 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | ||
169 | { | ||
170 | dbcon.Open(); | ||
171 | |||
172 | using (IDbCommand result = m_database.Query(dbcon, | ||
173 | "SELECT * FROM regions WHERE regionName LIKE ?name", | ||
174 | param)) | ||
175 | { | ||
176 | using (IDataReader reader = result.ExecuteReader()) | ||
177 | { | ||
178 | RegionProfileData row; | ||
179 | |||
180 | List<RegionProfileData> rows = new List<RegionProfileData>(); | ||
181 | |||
182 | while (rows.Count < maxNum && (row = m_database.readSimRow(reader)) != null) | ||
183 | rows.Add(row); | ||
184 | |||
185 | return rows; | ||
186 | } | ||
187 | } | ||
188 | } | ||
189 | } | ||
190 | catch (Exception e) | ||
191 | { | ||
192 | m_log.Error(e.Message, e); | ||
193 | return null; | ||
194 | } | ||
195 | } | ||
196 | |||
197 | /// <summary> | ||
198 | /// Returns a sim profile from it's location | ||
199 | /// </summary> | ||
200 | /// <param name="handle">Region location handle</param> | ||
201 | /// <returns>Sim profile</returns> | ||
202 | override public RegionProfileData GetProfileByHandle(ulong handle) | ||
203 | { | ||
204 | try | ||
205 | { | ||
206 | Dictionary<string, object> param = new Dictionary<string, object>(); | ||
207 | param["?handle"] = handle.ToString(); | ||
208 | |||
209 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | ||
210 | { | ||
211 | dbcon.Open(); | ||
212 | |||
213 | using (IDbCommand result = m_database.Query(dbcon, "SELECT * FROM regions WHERE regionHandle = ?handle", param)) | ||
214 | { | ||
215 | using (IDataReader reader = result.ExecuteReader()) | ||
216 | { | ||
217 | RegionProfileData row = m_database.readSimRow(reader); | ||
218 | return row; | ||
219 | } | ||
220 | } | ||
221 | } | ||
222 | } | ||
223 | catch (Exception e) | ||
224 | { | ||
225 | m_log.Error(e.Message, e); | ||
226 | return null; | ||
227 | } | ||
228 | } | ||
229 | |||
230 | /// <summary> | ||
231 | /// Returns a sim profile from it's UUID | ||
232 | /// </summary> | ||
233 | /// <param name="uuid">The region UUID</param> | ||
234 | /// <returns>The sim profile</returns> | ||
235 | override public RegionProfileData GetProfileByUUID(UUID uuid) | ||
236 | { | ||
237 | try | ||
238 | { | ||
239 | Dictionary<string, object> param = new Dictionary<string, object>(); | ||
240 | param["?uuid"] = uuid.ToString(); | ||
241 | |||
242 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | ||
243 | { | ||
244 | dbcon.Open(); | ||
245 | |||
246 | using (IDbCommand result = m_database.Query(dbcon, "SELECT * FROM regions WHERE uuid = ?uuid", param)) | ||
247 | { | ||
248 | using (IDataReader reader = result.ExecuteReader()) | ||
249 | { | ||
250 | RegionProfileData row = m_database.readSimRow(reader); | ||
251 | return row; | ||
252 | } | ||
253 | } | ||
254 | } | ||
255 | } | ||
256 | catch (Exception e) | ||
257 | { | ||
258 | m_log.Error(e.Message, e); | ||
259 | return null; | ||
260 | } | ||
261 | } | ||
262 | |||
263 | /// <summary> | ||
264 | /// Returns a sim profile from it's Region name string | ||
265 | /// </summary> | ||
266 | /// <returns>The sim profile</returns> | ||
267 | override public RegionProfileData GetProfileByString(string regionName) | ||
268 | { | ||
269 | if (regionName.Length > 2) | ||
270 | { | ||
271 | try | ||
272 | { | ||
273 | Dictionary<string, object> param = new Dictionary<string, object>(); | ||
274 | // Add % because this is a like query. | ||
275 | param["?regionName"] = regionName + "%"; | ||
276 | |||
277 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | ||
278 | { | ||
279 | dbcon.Open(); | ||
280 | |||
281 | // Order by statement will return shorter matches first. Only returns one record or no record. | ||
282 | using (IDbCommand result = m_database.Query(dbcon, | ||
283 | "SELECT * FROM regions WHERE regionName like ?regionName order by LENGTH(regionName) asc LIMIT 1", | ||
284 | param)) | ||
285 | { | ||
286 | using (IDataReader reader = result.ExecuteReader()) | ||
287 | { | ||
288 | RegionProfileData row = m_database.readSimRow(reader); | ||
289 | return row; | ||
290 | } | ||
291 | } | ||
292 | } | ||
293 | } | ||
294 | catch (Exception e) | ||
295 | { | ||
296 | m_log.Error(e.Message, e); | ||
297 | return null; | ||
298 | } | ||
299 | } | ||
300 | |||
301 | m_log.Error("[GRID DB]: Searched for a Region Name shorter then 3 characters"); | ||
302 | return null; | ||
303 | } | ||
304 | |||
305 | /// <summary> | ||
306 | /// Adds a new profile to the database | ||
307 | /// </summary> | ||
308 | /// <param name="profile">The profile to add</param> | ||
309 | /// <returns>Successful?</returns> | ||
310 | override public DataResponse StoreProfile(RegionProfileData profile) | ||
311 | { | ||
312 | try | ||
313 | { | ||
314 | if (m_database.insertRegion(profile)) | ||
315 | return DataResponse.RESPONSE_OK; | ||
316 | else | ||
317 | return DataResponse.RESPONSE_ERROR; | ||
318 | } | ||
319 | catch | ||
320 | { | ||
321 | return DataResponse.RESPONSE_ERROR; | ||
322 | } | ||
323 | } | ||
324 | |||
325 | /// <summary> | ||
326 | /// Deletes a sim profile from the database | ||
327 | /// </summary> | ||
328 | /// <param name="uuid">the sim UUID</param> | ||
329 | /// <returns>Successful?</returns> | ||
330 | //public DataResponse DeleteProfile(RegionProfileData profile) | ||
331 | override public DataResponse DeleteProfile(string uuid) | ||
332 | { | ||
333 | try | ||
334 | { | ||
335 | if (m_database.deleteRegion(uuid)) | ||
336 | return DataResponse.RESPONSE_OK; | ||
337 | else | ||
338 | return DataResponse.RESPONSE_ERROR; | ||
339 | } | ||
340 | catch | ||
341 | { | ||
342 | return DataResponse.RESPONSE_ERROR; | ||
343 | } | ||
344 | } | ||
345 | |||
346 | /// <summary> | ||
347 | /// DEPRECATED. Attempts to authenticate a region by comparing a shared secret. | ||
348 | /// </summary> | ||
349 | /// <param name="uuid">The UUID of the challenger</param> | ||
350 | /// <param name="handle">The attempted regionHandle of the challenger</param> | ||
351 | /// <param name="authkey">The secret</param> | ||
352 | /// <returns>Whether the secret and regionhandle match the database entry for UUID</returns> | ||
353 | override public bool AuthenticateSim(UUID uuid, ulong handle, string authkey) | ||
354 | { | ||
355 | bool throwHissyFit = false; // Should be true by 1.0 | ||
356 | |||
357 | if (throwHissyFit) | ||
358 | throw new Exception("CRYPTOWEAK AUTHENTICATE: Refusing to authenticate due to replay potential."); | ||
359 | |||
360 | RegionProfileData data = GetProfileByUUID(uuid); | ||
361 | |||
362 | return (handle == data.regionHandle && authkey == data.regionSecret); | ||
363 | } | ||
364 | |||
365 | /// <summary> | ||
366 | /// NOT YET FUNCTIONAL. Provides a cryptographic authentication of a region | ||
367 | /// </summary> | ||
368 | /// <remarks>This requires a security audit.</remarks> | ||
369 | /// <param name="uuid"></param> | ||
370 | /// <param name="handle"></param> | ||
371 | /// <param name="authhash"></param> | ||
372 | /// <param name="challenge"></param> | ||
373 | /// <returns></returns> | ||
374 | public bool AuthenticateSim(UUID uuid, ulong handle, string authhash, string challenge) | ||
375 | { | ||
376 | // SHA512Managed HashProvider = new SHA512Managed(); | ||
377 | // Encoding TextProvider = new UTF8Encoding(); | ||
378 | |||
379 | // byte[] stream = TextProvider.GetBytes(uuid.ToString() + ":" + handle.ToString() + ":" + challenge); | ||
380 | // byte[] hash = HashProvider.ComputeHash(stream); | ||
381 | |||
382 | return false; | ||
383 | } | ||
384 | |||
385 | /// <summary> | ||
386 | /// Adds a location reservation | ||
387 | /// </summary> | ||
388 | /// <param name="x">x coordinate</param> | ||
389 | /// <param name="y">y coordinate</param> | ||
390 | /// <returns></returns> | ||
391 | override public ReservationData GetReservationAtPoint(uint x, uint y) | ||
392 | { | ||
393 | try | ||
394 | { | ||
395 | Dictionary<string, object> param = new Dictionary<string, object>(); | ||
396 | param["?x"] = x.ToString(); | ||
397 | param["?y"] = y.ToString(); | ||
398 | |||
399 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | ||
400 | { | ||
401 | dbcon.Open(); | ||
402 | |||
403 | using (IDbCommand result = m_database.Query(dbcon, | ||
404 | "SELECT * FROM reservations WHERE resXMin <= ?x AND resXMax >= ?x AND resYMin <= ?y AND resYMax >= ?y", | ||
405 | param)) | ||
406 | { | ||
407 | using (IDataReader reader = result.ExecuteReader()) | ||
408 | { | ||
409 | ReservationData row = m_database.readReservationRow(reader); | ||
410 | return row; | ||
411 | } | ||
412 | } | ||
413 | } | ||
414 | } | ||
415 | catch (Exception e) | ||
416 | { | ||
417 | m_log.Error(e.Message, e); | ||
418 | return null; | ||
419 | } | ||
420 | } | ||
421 | } | ||
422 | } | ||
diff --git a/OpenSim/Data/MySQL/MySQLLogData.cs b/OpenSim/Data/MySQL/MySQLLogData.cs deleted file mode 100644 index 304883c..0000000 --- a/OpenSim/Data/MySQL/MySQLLogData.cs +++ /dev/null | |||
@@ -1,166 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | using System; | ||
28 | using System.Collections.Generic; | ||
29 | using System.Reflection; | ||
30 | using log4net; | ||
31 | using OpenSim.Framework; | ||
32 | |||
33 | namespace OpenSim.Data.MySQL | ||
34 | { | ||
35 | /// <summary> | ||
36 | /// An interface to the log database for MySQL | ||
37 | /// </summary> | ||
38 | internal class MySQLLogData : ILogDataPlugin | ||
39 | { | ||
40 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
41 | |||
42 | /// <summary> | ||
43 | /// The database manager | ||
44 | /// </summary> | ||
45 | public MySQLManager database; | ||
46 | |||
47 | public void Initialise() | ||
48 | { | ||
49 | m_log.Info("[MySQLLogData]: " + Name + " cannot be default-initialized!"); | ||
50 | throw new PluginNotInitialisedException (Name); | ||
51 | } | ||
52 | |||
53 | /// <summary> | ||
54 | /// Artificial constructor called when the plugin is loaded | ||
55 | /// Uses the obsolete mysql_connection.ini if connect string is empty. | ||
56 | /// </summary> | ||
57 | /// <param name="connect">connect string</param> | ||
58 | public void Initialise(string connect) | ||
59 | { | ||
60 | if (connect != String.Empty) | ||
61 | { | ||
62 | database = new MySQLManager(connect); | ||
63 | } | ||
64 | else | ||
65 | { | ||
66 | m_log.Warn("Using deprecated mysql_connection.ini. Please update database_connect in GridServer_Config.xml and we'll use that instead"); | ||
67 | |||
68 | IniFile GridDataMySqlFile = new IniFile("mysql_connection.ini"); | ||
69 | string settingHostname = GridDataMySqlFile.ParseFileReadValue("hostname"); | ||
70 | string settingDatabase = GridDataMySqlFile.ParseFileReadValue("database"); | ||
71 | string settingUsername = GridDataMySqlFile.ParseFileReadValue("username"); | ||
72 | string settingPassword = GridDataMySqlFile.ParseFileReadValue("password"); | ||
73 | string settingPooling = GridDataMySqlFile.ParseFileReadValue("pooling"); | ||
74 | string settingPort = GridDataMySqlFile.ParseFileReadValue("port"); | ||
75 | |||
76 | database = new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, | ||
77 | settingPooling, settingPort); | ||
78 | } | ||
79 | |||
80 | // This actually does the roll forward assembly stuff | ||
81 | Assembly assem = GetType().Assembly; | ||
82 | |||
83 | using (MySql.Data.MySqlClient.MySqlConnection dbcon = new MySql.Data.MySqlClient.MySqlConnection(connect)) | ||
84 | { | ||
85 | dbcon.Open(); | ||
86 | |||
87 | Migration m = new Migration(dbcon, assem, "LogStore"); | ||
88 | |||
89 | // TODO: After rev 6000, remove this. People should have | ||
90 | // been rolled onto the new migration code by then. | ||
91 | TestTables(m); | ||
92 | |||
93 | m.Update(); | ||
94 | } | ||
95 | } | ||
96 | |||
97 | /// <summary></summary> | ||
98 | /// <param name="m"></param> | ||
99 | private void TestTables(Migration m) | ||
100 | { | ||
101 | // under migrations, bail | ||
102 | if (m.Version > 0) | ||
103 | return; | ||
104 | |||
105 | Dictionary<string, string> tableList = new Dictionary<string, string>(); | ||
106 | tableList["logs"] = null; | ||
107 | database.GetTableVersion(tableList); | ||
108 | |||
109 | // migrations will handle it | ||
110 | if (tableList["logs"] == null) | ||
111 | return; | ||
112 | |||
113 | // we have the table, so pretend like we did the first migration in the past | ||
114 | if (m.Version == 0) | ||
115 | m.Version = 1; | ||
116 | } | ||
117 | |||
118 | /// <summary> | ||
119 | /// Saves a log item to the database | ||
120 | /// </summary> | ||
121 | /// <param name="serverDaemon">The daemon triggering the event</param> | ||
122 | /// <param name="target">The target of the action (region / agent UUID, etc)</param> | ||
123 | /// <param name="methodCall">The method call where the problem occured</param> | ||
124 | /// <param name="arguments">The arguments passed to the method</param> | ||
125 | /// <param name="priority">How critical is this?</param> | ||
126 | /// <param name="logMessage">The message to log</param> | ||
127 | public void saveLog(string serverDaemon, string target, string methodCall, string arguments, int priority, | ||
128 | string logMessage) | ||
129 | { | ||
130 | try | ||
131 | { | ||
132 | database.insertLogRow(serverDaemon, target, methodCall, arguments, priority, logMessage); | ||
133 | } | ||
134 | catch | ||
135 | { | ||
136 | } | ||
137 | } | ||
138 | |||
139 | /// <summary> | ||
140 | /// Returns the name of this DB provider | ||
141 | /// </summary> | ||
142 | /// <returns>A string containing the DB provider name</returns> | ||
143 | public string Name | ||
144 | { | ||
145 | get { return "MySQL Logdata Interface";} | ||
146 | } | ||
147 | |||
148 | /// <summary> | ||
149 | /// Closes the database provider | ||
150 | /// </summary> | ||
151 | /// <remarks>do nothing</remarks> | ||
152 | public void Dispose() | ||
153 | { | ||
154 | // Do nothing. | ||
155 | } | ||
156 | |||
157 | /// <summary> | ||
158 | /// Returns the version of this DB provider | ||
159 | /// </summary> | ||
160 | /// <returns>A string containing the provider version</returns> | ||
161 | public string Version | ||
162 | { | ||
163 | get { return "0.1"; } | ||
164 | } | ||
165 | } | ||
166 | } | ||
diff --git a/OpenSim/Data/MySQL/MySQLManager.cs b/OpenSim/Data/MySQL/MySQLManager.cs deleted file mode 100644 index ace2027..0000000 --- a/OpenSim/Data/MySQL/MySQLManager.cs +++ /dev/null | |||
@@ -1,1248 +0,0 @@ | |||
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.Data; | ||
32 | using System.IO; | ||
33 | using System.Reflection; | ||
34 | using log4net; | ||
35 | using MySql.Data.MySqlClient; | ||
36 | using OpenMetaverse; | ||
37 | using OpenSim.Framework; | ||
38 | |||
39 | namespace OpenSim.Data.MySQL | ||
40 | { | ||
41 | /// <summary> | ||
42 | /// A MySQL Database manager | ||
43 | /// </summary> | ||
44 | public class MySQLManager | ||
45 | { | ||
46 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
47 | |||
48 | /// <summary> | ||
49 | /// Connection string for ADO.net | ||
50 | /// </summary> | ||
51 | private string connectionString; | ||
52 | |||
53 | private object m_dbLock = new object(); | ||
54 | |||
55 | private const string m_waitTimeoutSelect = "select @@wait_timeout"; | ||
56 | |||
57 | /// <summary> | ||
58 | /// Wait timeout for our connection in ticks. | ||
59 | /// </summary> | ||
60 | private long m_waitTimeout; | ||
61 | |||
62 | /// <summary> | ||
63 | /// Make our storage of the timeout this amount smaller than it actually is, to give us a margin on long | ||
64 | /// running database operations. | ||
65 | /// </summary> | ||
66 | private long m_waitTimeoutLeeway = 60 * TimeSpan.TicksPerSecond; | ||
67 | |||
68 | /// <summary> | ||
69 | /// Holds the last tick time that the connection was used. | ||
70 | /// </summary> | ||
71 | private long m_lastConnectionUse; | ||
72 | |||
73 | /// <summary> | ||
74 | /// Initialises and creates a new MySQL connection and maintains it. | ||
75 | /// </summary> | ||
76 | /// <param name="hostname">The MySQL server being connected to</param> | ||
77 | /// <param name="database">The name of the MySQL database being used</param> | ||
78 | /// <param name="username">The username logging into the database</param> | ||
79 | /// <param name="password">The password for the user logging in</param> | ||
80 | /// <param name="cpooling">Whether to use connection pooling or not, can be one of the following: 'yes', 'true', 'no' or 'false', if unsure use 'false'.</param> | ||
81 | /// <param name="port">The MySQL server port</param> | ||
82 | public MySQLManager(string hostname, string database, string username, string password, string cpooling, | ||
83 | string port) | ||
84 | { | ||
85 | string s = "Server=" + hostname + ";Port=" + port + ";Database=" + database + ";User ID=" + | ||
86 | username + ";Password=" + password + ";Pooling=" + cpooling + ";"; | ||
87 | |||
88 | Initialise(s); | ||
89 | } | ||
90 | |||
91 | /// <summary> | ||
92 | /// Initialises and creates a new MySQL connection and maintains it. | ||
93 | /// </summary> | ||
94 | /// <param name="connect">connectionString</param> | ||
95 | public MySQLManager(String connect) | ||
96 | { | ||
97 | Initialise(connect); | ||
98 | } | ||
99 | |||
100 | /// <summary> | ||
101 | /// Initialises and creates a new MySQL connection and maintains it. | ||
102 | /// </summary> | ||
103 | /// <param name="connect">connectionString</param> | ||
104 | public void Initialise(String connect) | ||
105 | { | ||
106 | try | ||
107 | { | ||
108 | connectionString = connect; | ||
109 | //dbcon = new MySqlConnection(connectionString); | ||
110 | |||
111 | try | ||
112 | { | ||
113 | //dbcon.Open(); | ||
114 | } | ||
115 | catch(Exception e) | ||
116 | { | ||
117 | throw new Exception("Connection error while using connection string ["+connectionString+"]", e); | ||
118 | } | ||
119 | |||
120 | m_log.Info("[MYSQL]: Connection established"); | ||
121 | GetWaitTimeout(); | ||
122 | } | ||
123 | catch (Exception e) | ||
124 | { | ||
125 | throw new Exception("Error initialising MySql Database: " + e.ToString()); | ||
126 | } | ||
127 | } | ||
128 | |||
129 | /// <summary> | ||
130 | /// Get the wait_timeout value for our connection | ||
131 | /// </summary> | ||
132 | protected void GetWaitTimeout() | ||
133 | { | ||
134 | using (MySqlConnection dbcon = new MySqlConnection(connectionString)) | ||
135 | { | ||
136 | dbcon.Open(); | ||
137 | |||
138 | using (MySqlCommand cmd = new MySqlCommand(m_waitTimeoutSelect, dbcon)) | ||
139 | { | ||
140 | using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) | ||
141 | { | ||
142 | if (dbReader.Read()) | ||
143 | { | ||
144 | m_waitTimeout | ||
145 | = Convert.ToInt32(dbReader["@@wait_timeout"]) * TimeSpan.TicksPerSecond + m_waitTimeoutLeeway; | ||
146 | } | ||
147 | } | ||
148 | } | ||
149 | } | ||
150 | |||
151 | m_lastConnectionUse = DateTime.Now.Ticks; | ||
152 | |||
153 | m_log.DebugFormat( | ||
154 | "[REGION DB]: Connection wait timeout {0} seconds", m_waitTimeout / TimeSpan.TicksPerSecond); | ||
155 | } | ||
156 | |||
157 | public string ConnectionString | ||
158 | { | ||
159 | get { return connectionString; } | ||
160 | } | ||
161 | |||
162 | /// <summary> | ||
163 | /// Returns the version of this DB provider | ||
164 | /// </summary> | ||
165 | /// <returns>A string containing the DB provider</returns> | ||
166 | public string getVersion() | ||
167 | { | ||
168 | Module module = GetType().Module; | ||
169 | // string dllName = module.Assembly.ManifestModule.Name; | ||
170 | Version dllVersion = module.Assembly.GetName().Version; | ||
171 | |||
172 | return | ||
173 | string.Format("{0}.{1}.{2}.{3}", dllVersion.Major, dllVersion.Minor, dllVersion.Build, | ||
174 | dllVersion.Revision); | ||
175 | } | ||
176 | |||
177 | /// <summary> | ||
178 | /// Extract a named string resource from the embedded resources | ||
179 | /// </summary> | ||
180 | /// <param name="name">name of embedded resource</param> | ||
181 | /// <returns>string contained within the embedded resource</returns> | ||
182 | private string getResourceString(string name) | ||
183 | { | ||
184 | Assembly assem = GetType().Assembly; | ||
185 | string[] names = assem.GetManifestResourceNames(); | ||
186 | |||
187 | foreach (string s in names) | ||
188 | { | ||
189 | if (s.EndsWith(name)) | ||
190 | { | ||
191 | using (Stream resource = assem.GetManifestResourceStream(s)) | ||
192 | { | ||
193 | using (StreamReader resourceReader = new StreamReader(resource)) | ||
194 | { | ||
195 | string resourceString = resourceReader.ReadToEnd(); | ||
196 | return resourceString; | ||
197 | } | ||
198 | } | ||
199 | } | ||
200 | } | ||
201 | throw new Exception(string.Format("Resource '{0}' was not found", name)); | ||
202 | } | ||
203 | |||
204 | /// <summary> | ||
205 | /// Execute a SQL statement stored in a resource, as a string | ||
206 | /// </summary> | ||
207 | /// <param name="name">name of embedded resource</param> | ||
208 | public void ExecuteResourceSql(string name) | ||
209 | { | ||
210 | using (MySqlConnection dbcon = new MySqlConnection(connectionString)) | ||
211 | { | ||
212 | dbcon.Open(); | ||
213 | |||
214 | MySqlCommand cmd = new MySqlCommand(getResourceString(name), dbcon); | ||
215 | cmd.ExecuteNonQuery(); | ||
216 | } | ||
217 | } | ||
218 | |||
219 | /// <summary> | ||
220 | /// Execute a MySqlCommand | ||
221 | /// </summary> | ||
222 | /// <param name="sql">sql string to execute</param> | ||
223 | public void ExecuteSql(string sql) | ||
224 | { | ||
225 | using (MySqlConnection dbcon = new MySqlConnection(connectionString)) | ||
226 | { | ||
227 | dbcon.Open(); | ||
228 | |||
229 | MySqlCommand cmd = new MySqlCommand(sql, dbcon); | ||
230 | cmd.ExecuteNonQuery(); | ||
231 | } | ||
232 | } | ||
233 | |||
234 | public void ExecuteParameterizedSql(string sql, Dictionary<string, string> parameters) | ||
235 | { | ||
236 | using (MySqlConnection dbcon = new MySqlConnection(connectionString)) | ||
237 | { | ||
238 | dbcon.Open(); | ||
239 | |||
240 | MySqlCommand cmd = (MySqlCommand)dbcon.CreateCommand(); | ||
241 | cmd.CommandText = sql; | ||
242 | foreach (KeyValuePair<string, string> param in parameters) | ||
243 | { | ||
244 | cmd.Parameters.AddWithValue(param.Key, param.Value); | ||
245 | } | ||
246 | cmd.ExecuteNonQuery(); | ||
247 | } | ||
248 | } | ||
249 | |||
250 | /// <summary> | ||
251 | /// Given a list of tables, return the version of the tables, as seen in the database | ||
252 | /// </summary> | ||
253 | /// <param name="tableList"></param> | ||
254 | public void GetTableVersion(Dictionary<string, string> tableList) | ||
255 | { | ||
256 | lock (m_dbLock) | ||
257 | { | ||
258 | using (MySqlConnection dbcon = new MySqlConnection(connectionString)) | ||
259 | { | ||
260 | dbcon.Open(); | ||
261 | |||
262 | using (MySqlCommand tablesCmd = new MySqlCommand( | ||
263 | "SELECT TABLE_NAME, TABLE_COMMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA=?dbname", dbcon)) | ||
264 | { | ||
265 | tablesCmd.Parameters.AddWithValue("?dbname", dbcon.Database); | ||
266 | |||
267 | using (MySqlDataReader tables = tablesCmd.ExecuteReader()) | ||
268 | { | ||
269 | while (tables.Read()) | ||
270 | { | ||
271 | try | ||
272 | { | ||
273 | string tableName = (string)tables["TABLE_NAME"]; | ||
274 | string comment = (string)tables["TABLE_COMMENT"]; | ||
275 | if (tableList.ContainsKey(tableName)) | ||
276 | { | ||
277 | tableList[tableName] = comment; | ||
278 | } | ||
279 | } | ||
280 | catch (Exception e) | ||
281 | { | ||
282 | m_log.Error(e.Message, e); | ||
283 | } | ||
284 | } | ||
285 | } | ||
286 | } | ||
287 | } | ||
288 | } | ||
289 | } | ||
290 | |||
291 | // TODO: at some time this code should be cleaned up | ||
292 | |||
293 | /// <summary> | ||
294 | /// Runs a query with protection against SQL Injection by using parameterised input. | ||
295 | /// </summary> | ||
296 | /// <param name="dbcon">Database connection</param> | ||
297 | /// <param name="sql">The SQL string - replace any variables such as WHERE x = "y" with WHERE x = @y</param> | ||
298 | /// <param name="parameters">The parameters - index so that @y is indexed as 'y'</param> | ||
299 | /// <returns>A MySQL DB Command</returns> | ||
300 | public IDbCommand Query(MySqlConnection dbcon, string sql, Dictionary<string, object> parameters) | ||
301 | { | ||
302 | try | ||
303 | { | ||
304 | MySqlCommand dbcommand = (MySqlCommand)dbcon.CreateCommand(); | ||
305 | dbcommand.CommandText = sql; | ||
306 | foreach (KeyValuePair<string, object> param in parameters) | ||
307 | { | ||
308 | dbcommand.Parameters.AddWithValue(param.Key, param.Value); | ||
309 | } | ||
310 | |||
311 | return (IDbCommand)dbcommand; | ||
312 | } | ||
313 | catch (Exception e) | ||
314 | { | ||
315 | // Return null if it fails. | ||
316 | m_log.Error("Failed during Query generation: " + e.Message, e); | ||
317 | return null; | ||
318 | } | ||
319 | } | ||
320 | |||
321 | /// <summary> | ||
322 | /// Reads a region row from a database reader | ||
323 | /// </summary> | ||
324 | /// <param name="reader">An active database reader</param> | ||
325 | /// <returns>A region profile</returns> | ||
326 | public RegionProfileData readSimRow(IDataReader reader) | ||
327 | { | ||
328 | RegionProfileData retval = new RegionProfileData(); | ||
329 | |||
330 | if (reader.Read()) | ||
331 | { | ||
332 | // Region Main gotta-have-or-we-return-null parts | ||
333 | UInt64 tmp64; | ||
334 | if (!UInt64.TryParse(reader["regionHandle"].ToString(), out tmp64)) | ||
335 | { | ||
336 | return null; | ||
337 | } | ||
338 | else | ||
339 | { | ||
340 | retval.regionHandle = tmp64; | ||
341 | } | ||
342 | UUID tmp_uuid; | ||
343 | if (!UUID.TryParse((string)reader["uuid"], out tmp_uuid)) | ||
344 | { | ||
345 | return null; | ||
346 | } | ||
347 | else | ||
348 | { | ||
349 | retval.UUID = tmp_uuid; | ||
350 | } | ||
351 | |||
352 | // non-critical parts | ||
353 | retval.regionName = (string)reader["regionName"]; | ||
354 | retval.originUUID = new UUID((string) reader["originUUID"]); | ||
355 | |||
356 | // Secrets | ||
357 | retval.regionRecvKey = (string) reader["regionRecvKey"]; | ||
358 | retval.regionSecret = (string) reader["regionSecret"]; | ||
359 | retval.regionSendKey = (string) reader["regionSendKey"]; | ||
360 | |||
361 | // Region Server | ||
362 | retval.regionDataURI = (string) reader["regionDataURI"]; | ||
363 | retval.regionOnline = false; // Needs to be pinged before this can be set. | ||
364 | retval.serverIP = (string) reader["serverIP"]; | ||
365 | retval.serverPort = (uint) reader["serverPort"]; | ||
366 | retval.serverURI = (string) reader["serverURI"]; | ||
367 | retval.httpPort = Convert.ToUInt32(reader["serverHttpPort"].ToString()); | ||
368 | retval.remotingPort = Convert.ToUInt32(reader["serverRemotingPort"].ToString()); | ||
369 | |||
370 | // Location | ||
371 | retval.regionLocX = Convert.ToUInt32(reader["locX"].ToString()); | ||
372 | retval.regionLocY = Convert.ToUInt32(reader["locY"].ToString()); | ||
373 | retval.regionLocZ = Convert.ToUInt32(reader["locZ"].ToString()); | ||
374 | |||
375 | // Neighbours - 0 = No Override | ||
376 | retval.regionEastOverrideHandle = Convert.ToUInt64(reader["eastOverrideHandle"].ToString()); | ||
377 | retval.regionWestOverrideHandle = Convert.ToUInt64(reader["westOverrideHandle"].ToString()); | ||
378 | retval.regionSouthOverrideHandle = Convert.ToUInt64(reader["southOverrideHandle"].ToString()); | ||
379 | retval.regionNorthOverrideHandle = Convert.ToUInt64(reader["northOverrideHandle"].ToString()); | ||
380 | |||
381 | // Assets | ||
382 | retval.regionAssetURI = (string) reader["regionAssetURI"]; | ||
383 | retval.regionAssetRecvKey = (string) reader["regionAssetRecvKey"]; | ||
384 | retval.regionAssetSendKey = (string) reader["regionAssetSendKey"]; | ||
385 | |||
386 | // Userserver | ||
387 | retval.regionUserURI = (string) reader["regionUserURI"]; | ||
388 | retval.regionUserRecvKey = (string) reader["regionUserRecvKey"]; | ||
389 | retval.regionUserSendKey = (string) reader["regionUserSendKey"]; | ||
390 | |||
391 | // World Map Addition | ||
392 | UUID.TryParse((string)reader["regionMapTexture"], out retval.regionMapTextureID); | ||
393 | UUID.TryParse((string)reader["owner_uuid"], out retval.owner_uuid); | ||
394 | retval.maturity = Convert.ToUInt32(reader["access"]); | ||
395 | } | ||
396 | else | ||
397 | { | ||
398 | return null; | ||
399 | } | ||
400 | return retval; | ||
401 | } | ||
402 | |||
403 | /// <summary> | ||
404 | /// Reads a reservation row from a database reader | ||
405 | /// </summary> | ||
406 | /// <param name="reader">An active database reader</param> | ||
407 | /// <returns>A reservation data object</returns> | ||
408 | public ReservationData readReservationRow(IDataReader reader) | ||
409 | { | ||
410 | ReservationData retval = new ReservationData(); | ||
411 | if (reader.Read()) | ||
412 | { | ||
413 | retval.gridRecvKey = (string) reader["gridRecvKey"]; | ||
414 | retval.gridSendKey = (string) reader["gridSendKey"]; | ||
415 | retval.reservationCompany = (string) reader["resCompany"]; | ||
416 | retval.reservationMaxX = Convert.ToInt32(reader["resXMax"].ToString()); | ||
417 | retval.reservationMaxY = Convert.ToInt32(reader["resYMax"].ToString()); | ||
418 | retval.reservationMinX = Convert.ToInt32(reader["resXMin"].ToString()); | ||
419 | retval.reservationMinY = Convert.ToInt32(reader["resYMin"].ToString()); | ||
420 | retval.reservationName = (string) reader["resName"]; | ||
421 | retval.status = Convert.ToInt32(reader["status"].ToString()) == 1; | ||
422 | UUID tmp; | ||
423 | UUID.TryParse((string) reader["userUUID"], out tmp); | ||
424 | retval.userUUID = tmp; | ||
425 | } | ||
426 | else | ||
427 | { | ||
428 | return null; | ||
429 | } | ||
430 | return retval; | ||
431 | } | ||
432 | |||
433 | /// <summary> | ||
434 | /// Reads an agent row from a database reader | ||
435 | /// </summary> | ||
436 | /// <param name="reader">An active database reader</param> | ||
437 | /// <returns>A user session agent</returns> | ||
438 | public UserAgentData readAgentRow(IDataReader reader) | ||
439 | { | ||
440 | UserAgentData retval = new UserAgentData(); | ||
441 | |||
442 | if (reader.Read()) | ||
443 | { | ||
444 | // Agent IDs | ||
445 | UUID tmp; | ||
446 | if (!UUID.TryParse((string)reader["UUID"], out tmp)) | ||
447 | return null; | ||
448 | retval.ProfileID = tmp; | ||
449 | |||
450 | UUID.TryParse((string) reader["sessionID"], out tmp); | ||
451 | retval.SessionID = tmp; | ||
452 | |||
453 | UUID.TryParse((string)reader["secureSessionID"], out tmp); | ||
454 | retval.SecureSessionID = tmp; | ||
455 | |||
456 | // Agent Who? | ||
457 | retval.AgentIP = (string) reader["agentIP"]; | ||
458 | retval.AgentPort = Convert.ToUInt32(reader["agentPort"].ToString()); | ||
459 | retval.AgentOnline = Convert.ToBoolean(Convert.ToInt16(reader["agentOnline"].ToString())); | ||
460 | |||
461 | // Login/Logout times (UNIX Epoch) | ||
462 | retval.LoginTime = Convert.ToInt32(reader["loginTime"].ToString()); | ||
463 | retval.LogoutTime = Convert.ToInt32(reader["logoutTime"].ToString()); | ||
464 | |||
465 | // Current position | ||
466 | retval.Region = new UUID((string)reader["currentRegion"]); | ||
467 | retval.Handle = Convert.ToUInt64(reader["currentHandle"].ToString()); | ||
468 | Vector3 tmp_v; | ||
469 | Vector3.TryParse((string) reader["currentPos"], out tmp_v); | ||
470 | retval.Position = tmp_v; | ||
471 | Vector3.TryParse((string)reader["currentLookAt"], out tmp_v); | ||
472 | retval.LookAt = tmp_v; | ||
473 | } | ||
474 | else | ||
475 | { | ||
476 | return null; | ||
477 | } | ||
478 | return retval; | ||
479 | } | ||
480 | |||
481 | /// <summary> | ||
482 | /// Reads a user profile from an active data reader | ||
483 | /// </summary> | ||
484 | /// <param name="reader">An active database reader</param> | ||
485 | /// <returns>A user profile</returns> | ||
486 | public UserProfileData readUserRow(IDataReader reader) | ||
487 | { | ||
488 | UserProfileData retval = new UserProfileData(); | ||
489 | |||
490 | if (reader.Read()) | ||
491 | { | ||
492 | UUID id; | ||
493 | if (!UUID.TryParse((string)reader["UUID"], out id)) | ||
494 | return null; | ||
495 | |||
496 | retval.ID = id; | ||
497 | retval.FirstName = (string) reader["username"]; | ||
498 | retval.SurName = (string) reader["lastname"]; | ||
499 | retval.Email = (reader.IsDBNull(reader.GetOrdinal("email"))) ? "" : (string) reader["email"]; | ||
500 | |||
501 | retval.PasswordHash = (string) reader["passwordHash"]; | ||
502 | retval.PasswordSalt = (string) reader["passwordSalt"]; | ||
503 | |||
504 | retval.HomeRegion = Convert.ToUInt64(reader["homeRegion"].ToString()); | ||
505 | retval.HomeLocation = new Vector3( | ||
506 | Convert.ToSingle(reader["homeLocationX"].ToString()), | ||
507 | Convert.ToSingle(reader["homeLocationY"].ToString()), | ||
508 | Convert.ToSingle(reader["homeLocationZ"].ToString())); | ||
509 | retval.HomeLookAt = new Vector3( | ||
510 | Convert.ToSingle(reader["homeLookAtX"].ToString()), | ||
511 | Convert.ToSingle(reader["homeLookAtY"].ToString()), | ||
512 | Convert.ToSingle(reader["homeLookAtZ"].ToString())); | ||
513 | |||
514 | UUID regionID = UUID.Zero; | ||
515 | UUID.TryParse(reader["homeRegionID"].ToString(), out regionID); // it's ok if it doesn't work; just use UUID.Zero | ||
516 | retval.HomeRegionID = regionID; | ||
517 | |||
518 | retval.Created = Convert.ToInt32(reader["created"].ToString()); | ||
519 | retval.LastLogin = Convert.ToInt32(reader["lastLogin"].ToString()); | ||
520 | |||
521 | retval.UserInventoryURI = (string) reader["userInventoryURI"]; | ||
522 | retval.UserAssetURI = (string) reader["userAssetURI"]; | ||
523 | |||
524 | retval.CanDoMask = Convert.ToUInt32(reader["profileCanDoMask"].ToString()); | ||
525 | retval.WantDoMask = Convert.ToUInt32(reader["profileWantDoMask"].ToString()); | ||
526 | |||
527 | if (reader.IsDBNull(reader.GetOrdinal("profileAboutText"))) | ||
528 | retval.AboutText = ""; | ||
529 | else | ||
530 | retval.AboutText = (string) reader["profileAboutText"]; | ||
531 | |||
532 | if (reader.IsDBNull(reader.GetOrdinal("profileFirstText"))) | ||
533 | retval.FirstLifeAboutText = ""; | ||
534 | else | ||
535 | retval.FirstLifeAboutText = (string)reader["profileFirstText"]; | ||
536 | |||
537 | if (reader.IsDBNull(reader.GetOrdinal("profileImage"))) | ||
538 | retval.Image = UUID.Zero; | ||
539 | else { | ||
540 | UUID tmp; | ||
541 | UUID.TryParse((string)reader["profileImage"], out tmp); | ||
542 | retval.Image = tmp; | ||
543 | } | ||
544 | |||
545 | if (reader.IsDBNull(reader.GetOrdinal("profileFirstImage"))) | ||
546 | retval.FirstLifeImage = UUID.Zero; | ||
547 | else { | ||
548 | UUID tmp; | ||
549 | UUID.TryParse((string)reader["profileFirstImage"], out tmp); | ||
550 | retval.FirstLifeImage = tmp; | ||
551 | } | ||
552 | |||
553 | if (reader.IsDBNull(reader.GetOrdinal("webLoginKey"))) | ||
554 | { | ||
555 | retval.WebLoginKey = UUID.Zero; | ||
556 | } | ||
557 | else | ||
558 | { | ||
559 | UUID tmp; | ||
560 | UUID.TryParse((string)reader["webLoginKey"], out tmp); | ||
561 | retval.WebLoginKey = tmp; | ||
562 | } | ||
563 | |||
564 | retval.UserFlags = Convert.ToInt32(reader["userFlags"].ToString()); | ||
565 | retval.GodLevel = Convert.ToInt32(reader["godLevel"].ToString()); | ||
566 | if (reader.IsDBNull(reader.GetOrdinal("customType"))) | ||
567 | retval.CustomType = ""; | ||
568 | else | ||
569 | retval.CustomType = reader["customType"].ToString(); | ||
570 | |||
571 | if (reader.IsDBNull(reader.GetOrdinal("partner"))) | ||
572 | { | ||
573 | retval.Partner = UUID.Zero; | ||
574 | } | ||
575 | else | ||
576 | { | ||
577 | UUID tmp; | ||
578 | UUID.TryParse((string)reader["partner"], out tmp); | ||
579 | retval.Partner = tmp; | ||
580 | } | ||
581 | } | ||
582 | else | ||
583 | { | ||
584 | return null; | ||
585 | } | ||
586 | return retval; | ||
587 | } | ||
588 | |||
589 | /// <summary> | ||
590 | /// Reads an avatar appearence from an active data reader | ||
591 | /// </summary> | ||
592 | /// <param name="reader">An active database reader</param> | ||
593 | /// <returns>An avatar appearence</returns> | ||
594 | public AvatarAppearance readAppearanceRow(IDataReader reader) | ||
595 | { | ||
596 | AvatarAppearance appearance = null; | ||
597 | if (reader.Read()) | ||
598 | { | ||
599 | appearance = new AvatarAppearance(); | ||
600 | appearance.Owner = new UUID((string)reader["owner"]); | ||
601 | appearance.Serial = Convert.ToInt32(reader["serial"]); | ||
602 | appearance.VisualParams = (byte[])reader["visual_params"]; | ||
603 | appearance.Texture = new Primitive.TextureEntry((byte[])reader["texture"], 0, ((byte[])reader["texture"]).Length); | ||
604 | appearance.AvatarHeight = (float)Convert.ToDouble(reader["avatar_height"]); | ||
605 | appearance.BodyItem = new UUID((string)reader["body_item"]); | ||
606 | appearance.BodyAsset = new UUID((string)reader["body_asset"]); | ||
607 | appearance.SkinItem = new UUID((string)reader["skin_item"]); | ||
608 | appearance.SkinAsset = new UUID((string)reader["skin_asset"]); | ||
609 | appearance.HairItem = new UUID((string)reader["hair_item"]); | ||
610 | appearance.HairAsset = new UUID((string)reader["hair_asset"]); | ||
611 | appearance.EyesItem = new UUID((string)reader["eyes_item"]); | ||
612 | appearance.EyesAsset = new UUID((string)reader["eyes_asset"]); | ||
613 | appearance.ShirtItem = new UUID((string)reader["shirt_item"]); | ||
614 | appearance.ShirtAsset = new UUID((string)reader["shirt_asset"]); | ||
615 | appearance.PantsItem = new UUID((string)reader["pants_item"]); | ||
616 | appearance.PantsAsset = new UUID((string)reader["pants_asset"]); | ||
617 | appearance.ShoesItem = new UUID((string)reader["shoes_item"]); | ||
618 | appearance.ShoesAsset = new UUID((string)reader["shoes_asset"]); | ||
619 | appearance.SocksItem = new UUID((string)reader["socks_item"]); | ||
620 | appearance.SocksAsset = new UUID((string)reader["socks_asset"]); | ||
621 | appearance.JacketItem = new UUID((string)reader["jacket_item"]); | ||
622 | appearance.JacketAsset = new UUID((string)reader["jacket_asset"]); | ||
623 | appearance.GlovesItem = new UUID((string)reader["gloves_item"]); | ||
624 | appearance.GlovesAsset = new UUID((string)reader["gloves_asset"]); | ||
625 | appearance.UnderShirtItem = new UUID((string)reader["undershirt_item"]); | ||
626 | appearance.UnderShirtAsset = new UUID((string)reader["undershirt_asset"]); | ||
627 | appearance.UnderPantsItem = new UUID((string)reader["underpants_item"]); | ||
628 | appearance.UnderPantsAsset = new UUID((string)reader["underpants_asset"]); | ||
629 | appearance.SkirtItem = new UUID((string)reader["skirt_item"]); | ||
630 | appearance.SkirtAsset = new UUID((string)reader["skirt_asset"]); | ||
631 | } | ||
632 | return appearance; | ||
633 | } | ||
634 | |||
635 | // Read attachment list from data reader | ||
636 | public Hashtable readAttachments(IDataReader r) | ||
637 | { | ||
638 | Hashtable ret = new Hashtable(); | ||
639 | |||
640 | while (r.Read()) | ||
641 | { | ||
642 | int attachpoint = Convert.ToInt32(r["attachpoint"]); | ||
643 | if (ret.ContainsKey(attachpoint)) | ||
644 | continue; | ||
645 | Hashtable item = new Hashtable(); | ||
646 | item.Add("item", r["item"].ToString()); | ||
647 | item.Add("asset", r["asset"].ToString()); | ||
648 | |||
649 | ret.Add(attachpoint, item); | ||
650 | } | ||
651 | |||
652 | return ret; | ||
653 | } | ||
654 | |||
655 | /// <summary> | ||
656 | /// Inserts a new row into the log database | ||
657 | /// </summary> | ||
658 | /// <param name="serverDaemon">The daemon which triggered this event</param> | ||
659 | /// <param name="target">Who were we operating on when this occured (region UUID, user UUID, etc)</param> | ||
660 | /// <param name="methodCall">The method call where the problem occured</param> | ||
661 | /// <param name="arguments">The arguments passed to the method</param> | ||
662 | /// <param name="priority">How critical is this?</param> | ||
663 | /// <param name="logMessage">Extra message info</param> | ||
664 | /// <returns>Saved successfully?</returns> | ||
665 | public bool insertLogRow(string serverDaemon, string target, string methodCall, string arguments, int priority, | ||
666 | string logMessage) | ||
667 | { | ||
668 | string sql = "INSERT INTO logs (`target`, `server`, `method`, `arguments`, `priority`, `message`) VALUES "; | ||
669 | sql += "(?target, ?server, ?method, ?arguments, ?priority, ?message)"; | ||
670 | |||
671 | Dictionary<string, object> parameters = new Dictionary<string, object>(); | ||
672 | parameters["?server"] = serverDaemon; | ||
673 | parameters["?target"] = target; | ||
674 | parameters["?method"] = methodCall; | ||
675 | parameters["?arguments"] = arguments; | ||
676 | parameters["?priority"] = priority.ToString(); | ||
677 | parameters["?message"] = logMessage; | ||
678 | |||
679 | bool returnval = false; | ||
680 | |||
681 | try | ||
682 | { | ||
683 | using (MySqlConnection dbcon = new MySqlConnection(connectionString)) | ||
684 | { | ||
685 | dbcon.Open(); | ||
686 | |||
687 | IDbCommand result = Query(dbcon, sql, parameters); | ||
688 | |||
689 | if (result.ExecuteNonQuery() == 1) | ||
690 | returnval = true; | ||
691 | |||
692 | result.Dispose(); | ||
693 | } | ||
694 | } | ||
695 | catch (Exception e) | ||
696 | { | ||
697 | m_log.Error(e.ToString()); | ||
698 | return false; | ||
699 | } | ||
700 | |||
701 | return returnval; | ||
702 | } | ||
703 | |||
704 | /// <summary> | ||
705 | /// Creates a new user and inserts it into the database | ||
706 | /// </summary> | ||
707 | /// <param name="uuid">User ID</param> | ||
708 | /// <param name="username">First part of the login</param> | ||
709 | /// <param name="lastname">Second part of the login</param> | ||
710 | /// <param name="passwordHash">A salted hash of the users password</param> | ||
711 | /// <param name="passwordSalt">The salt used for the password hash</param> | ||
712 | /// <param name="homeRegion">A regionHandle of the users home region</param> | ||
713 | /// <param name="homeRegionID"> The UUID of the user's home region</param> | ||
714 | /// <param name="homeLocX">Home region position vector</param> | ||
715 | /// <param name="homeLocY">Home region position vector</param> | ||
716 | /// <param name="homeLocZ">Home region position vector</param> | ||
717 | /// <param name="homeLookAtX">Home region 'look at' vector</param> | ||
718 | /// <param name="homeLookAtY">Home region 'look at' vector</param> | ||
719 | /// <param name="homeLookAtZ">Home region 'look at' vector</param> | ||
720 | /// <param name="created">Account created (unix timestamp)</param> | ||
721 | /// <param name="lastlogin">Last login (unix timestamp)</param> | ||
722 | /// <param name="inventoryURI">Users inventory URI</param> | ||
723 | /// <param name="assetURI">Users asset URI</param> | ||
724 | /// <param name="canDoMask">I can do mask</param> | ||
725 | /// <param name="wantDoMask">I want to do mask</param> | ||
726 | /// <param name="aboutText">Profile text</param> | ||
727 | /// <param name="firstText">Firstlife text</param> | ||
728 | /// <param name="profileImage">UUID for profile image</param> | ||
729 | /// <param name="firstImage">UUID for firstlife image</param> | ||
730 | /// <param name="webLoginKey">Ignored</param> | ||
731 | /// <returns>Success?</returns> | ||
732 | public bool insertUserRow(UUID uuid, string username, string lastname, string email, string passwordHash, | ||
733 | string passwordSalt, UInt64 homeRegion, UUID homeRegionID, float homeLocX, float homeLocY, float homeLocZ, | ||
734 | float homeLookAtX, float homeLookAtY, float homeLookAtZ, int created, int lastlogin, | ||
735 | string inventoryURI, string assetURI, uint canDoMask, uint wantDoMask, | ||
736 | string aboutText, string firstText, | ||
737 | UUID profileImage, UUID firstImage, UUID webLoginKey, int userFlags, int godLevel, string customType, UUID partner) | ||
738 | { | ||
739 | m_log.Debug("[MySQLManager]: Creating profile for \"" + username + " " + lastname + "\" (" + uuid + ")"); | ||
740 | string sql = | ||
741 | "INSERT INTO users (`UUID`, `username`, `lastname`, `email`, `passwordHash`, `passwordSalt`, `homeRegion`, `homeRegionID`, "; | ||
742 | sql += | ||
743 | "`homeLocationX`, `homeLocationY`, `homeLocationZ`, `homeLookAtX`, `homeLookAtY`, `homeLookAtZ`, `created`, "; | ||
744 | sql += | ||
745 | "`lastLogin`, `userInventoryURI`, `userAssetURI`, `profileCanDoMask`, `profileWantDoMask`, `profileAboutText`, "; | ||
746 | sql += "`profileFirstText`, `profileImage`, `profileFirstImage`, `webLoginKey`, `userFlags`, `godLevel`, `customType`, `partner`) VALUES "; | ||
747 | |||
748 | sql += "(?UUID, ?username, ?lastname, ?email, ?passwordHash, ?passwordSalt, ?homeRegion, ?homeRegionID, "; | ||
749 | sql += | ||
750 | "?homeLocationX, ?homeLocationY, ?homeLocationZ, ?homeLookAtX, ?homeLookAtY, ?homeLookAtZ, ?created, "; | ||
751 | sql += | ||
752 | "?lastLogin, ?userInventoryURI, ?userAssetURI, ?profileCanDoMask, ?profileWantDoMask, ?profileAboutText, "; | ||
753 | sql += "?profileFirstText, ?profileImage, ?profileFirstImage, ?webLoginKey, ?userFlags, ?godLevel, ?customType, ?partner)"; | ||
754 | |||
755 | Dictionary<string, object> parameters = new Dictionary<string, object>(); | ||
756 | parameters["?UUID"] = uuid.ToString(); | ||
757 | parameters["?username"] = username; | ||
758 | parameters["?lastname"] = lastname; | ||
759 | parameters["?email"] = email; | ||
760 | parameters["?passwordHash"] = passwordHash; | ||
761 | parameters["?passwordSalt"] = passwordSalt; | ||
762 | parameters["?homeRegion"] = homeRegion; | ||
763 | parameters["?homeRegionID"] = homeRegionID.ToString(); | ||
764 | parameters["?homeLocationX"] = homeLocX; | ||
765 | parameters["?homeLocationY"] = homeLocY; | ||
766 | parameters["?homeLocationZ"] = homeLocZ; | ||
767 | parameters["?homeLookAtX"] = homeLookAtX; | ||
768 | parameters["?homeLookAtY"] = homeLookAtY; | ||
769 | parameters["?homeLookAtZ"] = homeLookAtZ; | ||
770 | parameters["?created"] = created; | ||
771 | parameters["?lastLogin"] = lastlogin; | ||
772 | parameters["?userInventoryURI"] = inventoryURI; | ||
773 | parameters["?userAssetURI"] = assetURI; | ||
774 | parameters["?profileCanDoMask"] = canDoMask; | ||
775 | parameters["?profileWantDoMask"] = wantDoMask; | ||
776 | parameters["?profileAboutText"] = aboutText; | ||
777 | parameters["?profileFirstText"] = firstText; | ||
778 | parameters["?profileImage"] = profileImage.ToString(); | ||
779 | parameters["?profileFirstImage"] = firstImage.ToString(); | ||
780 | parameters["?webLoginKey"] = webLoginKey.ToString(); | ||
781 | parameters["?userFlags"] = userFlags; | ||
782 | parameters["?godLevel"] = godLevel; | ||
783 | parameters["?customType"] = customType == null ? "" : customType; | ||
784 | parameters["?partner"] = partner.ToString(); | ||
785 | bool returnval = false; | ||
786 | |||
787 | try | ||
788 | { | ||
789 | using (MySqlConnection dbcon = new MySqlConnection(connectionString)) | ||
790 | { | ||
791 | dbcon.Open(); | ||
792 | |||
793 | IDbCommand result = Query(dbcon, sql, parameters); | ||
794 | |||
795 | if (result.ExecuteNonQuery() == 1) | ||
796 | returnval = true; | ||
797 | |||
798 | result.Dispose(); | ||
799 | } | ||
800 | } | ||
801 | catch (Exception e) | ||
802 | { | ||
803 | m_log.Error(e.ToString()); | ||
804 | return false; | ||
805 | } | ||
806 | |||
807 | //m_log.Debug("[MySQLManager]: Fetch user retval == " + returnval.ToString()); | ||
808 | return returnval; | ||
809 | } | ||
810 | |||
811 | /// <summary> | ||
812 | /// Update user data into the database where User ID = uuid | ||
813 | /// </summary> | ||
814 | /// <param name="uuid">User ID</param> | ||
815 | /// <param name="username">First part of the login</param> | ||
816 | /// <param name="lastname">Second part of the login</param> | ||
817 | /// <param name="passwordHash">A salted hash of the users password</param> | ||
818 | /// <param name="passwordSalt">The salt used for the password hash</param> | ||
819 | /// <param name="homeRegion">A regionHandle of the users home region</param> | ||
820 | /// <param name="homeLocX">Home region position vector</param> | ||
821 | /// <param name="homeLocY">Home region position vector</param> | ||
822 | /// <param name="homeLocZ">Home region position vector</param> | ||
823 | /// <param name="homeLookAtX">Home region 'look at' vector</param> | ||
824 | /// <param name="homeLookAtY">Home region 'look at' vector</param> | ||
825 | /// <param name="homeLookAtZ">Home region 'look at' vector</param> | ||
826 | /// <param name="created">Account created (unix timestamp)</param> | ||
827 | /// <param name="lastlogin">Last login (unix timestamp)</param> | ||
828 | /// <param name="inventoryURI">Users inventory URI</param> | ||
829 | /// <param name="assetURI">Users asset URI</param> | ||
830 | /// <param name="canDoMask">I can do mask</param> | ||
831 | /// <param name="wantDoMask">I want to do mask</param> | ||
832 | /// <param name="aboutText">Profile text</param> | ||
833 | /// <param name="firstText">Firstlife text</param> | ||
834 | /// <param name="profileImage">UUID for profile image</param> | ||
835 | /// <param name="firstImage">UUID for firstlife image</param> | ||
836 | /// <param name="webLoginKey">UUID for weblogin Key</param> | ||
837 | /// <returns>Success?</returns> | ||
838 | public bool updateUserRow(UUID uuid, string username, string lastname, string email, string passwordHash, | ||
839 | string passwordSalt, UInt64 homeRegion, UUID homeRegionID, float homeLocX, float homeLocY, float homeLocZ, | ||
840 | float homeLookAtX, float homeLookAtY, float homeLookAtZ, int created, int lastlogin, | ||
841 | string inventoryURI, string assetURI, uint canDoMask, uint wantDoMask, | ||
842 | string aboutText, string firstText, | ||
843 | UUID profileImage, UUID firstImage, UUID webLoginKey, int userFlags, int godLevel, string customType, UUID partner) | ||
844 | { | ||
845 | string sql = "UPDATE users SET `username` = ?username , `lastname` = ?lastname, `email` = ?email "; | ||
846 | sql += ", `passwordHash` = ?passwordHash , `passwordSalt` = ?passwordSalt , "; | ||
847 | sql += "`homeRegion` = ?homeRegion , `homeRegionID` = ?homeRegionID, `homeLocationX` = ?homeLocationX , "; | ||
848 | sql += "`homeLocationY` = ?homeLocationY , `homeLocationZ` = ?homeLocationZ , "; | ||
849 | sql += "`homeLookAtX` = ?homeLookAtX , `homeLookAtY` = ?homeLookAtY , "; | ||
850 | sql += "`homeLookAtZ` = ?homeLookAtZ , `created` = ?created , `lastLogin` = ?lastLogin , "; | ||
851 | sql += "`userInventoryURI` = ?userInventoryURI , `userAssetURI` = ?userAssetURI , "; | ||
852 | sql += "`profileCanDoMask` = ?profileCanDoMask , `profileWantDoMask` = ?profileWantDoMask , "; | ||
853 | sql += "`profileAboutText` = ?profileAboutText , `profileFirstText` = ?profileFirstText, "; | ||
854 | sql += "`profileImage` = ?profileImage , `profileFirstImage` = ?profileFirstImage , "; | ||
855 | sql += "`userFlags` = ?userFlags , `godLevel` = ?godLevel , "; | ||
856 | sql += "`customType` = ?customType , `partner` = ?partner , "; | ||
857 | sql += "`webLoginKey` = ?webLoginKey WHERE UUID = ?UUID"; | ||
858 | |||
859 | Dictionary<string, object> parameters = new Dictionary<string, object>(); | ||
860 | parameters["?UUID"] = uuid.ToString(); | ||
861 | parameters["?username"] = username; | ||
862 | parameters["?lastname"] = lastname; | ||
863 | parameters["?email"] = email; | ||
864 | parameters["?passwordHash"] = passwordHash; | ||
865 | parameters["?passwordSalt"] = passwordSalt; | ||
866 | parameters["?homeRegion"] = homeRegion; | ||
867 | parameters["?homeRegionID"] = homeRegionID.ToString(); | ||
868 | parameters["?homeLocationX"] = homeLocX; | ||
869 | parameters["?homeLocationY"] = homeLocY; | ||
870 | parameters["?homeLocationZ"] = homeLocZ; | ||
871 | parameters["?homeLookAtX"] = homeLookAtX; | ||
872 | parameters["?homeLookAtY"] = homeLookAtY; | ||
873 | parameters["?homeLookAtZ"] = homeLookAtZ; | ||
874 | parameters["?created"] = created; | ||
875 | parameters["?lastLogin"] = lastlogin; | ||
876 | parameters["?userInventoryURI"] = inventoryURI; | ||
877 | parameters["?userAssetURI"] = assetURI; | ||
878 | parameters["?profileCanDoMask"] = canDoMask; | ||
879 | parameters["?profileWantDoMask"] = wantDoMask; | ||
880 | parameters["?profileAboutText"] = aboutText; | ||
881 | parameters["?profileFirstText"] = firstText; | ||
882 | parameters["?profileImage"] = profileImage.ToString(); | ||
883 | parameters["?profileFirstImage"] = firstImage.ToString(); | ||
884 | parameters["?webLoginKey"] = webLoginKey.ToString(); | ||
885 | parameters["?userFlags"] = userFlags; | ||
886 | parameters["?godLevel"] = godLevel; | ||
887 | parameters["?customType"] = customType == null ? "" : customType; | ||
888 | parameters["?partner"] = partner.ToString(); | ||
889 | |||
890 | bool returnval = false; | ||
891 | try | ||
892 | { | ||
893 | using (MySqlConnection dbcon = new MySqlConnection(connectionString)) | ||
894 | { | ||
895 | dbcon.Open(); | ||
896 | |||
897 | IDbCommand result = Query(dbcon, sql, parameters); | ||
898 | |||
899 | if (result.ExecuteNonQuery() == 1) | ||
900 | returnval = true; | ||
901 | |||
902 | result.Dispose(); | ||
903 | } | ||
904 | } | ||
905 | catch (Exception e) | ||
906 | { | ||
907 | m_log.Error(e.ToString()); | ||
908 | return false; | ||
909 | } | ||
910 | |||
911 | //m_log.Debug("[MySQLManager]: update user retval == " + returnval.ToString()); | ||
912 | return returnval; | ||
913 | } | ||
914 | |||
915 | /// <summary> | ||
916 | /// Inserts a new region into the database | ||
917 | /// </summary> | ||
918 | /// <param name="regiondata">The region to insert</param> | ||
919 | /// <returns>Success?</returns> | ||
920 | public bool insertRegion(RegionProfileData regiondata) | ||
921 | { | ||
922 | bool GRID_ONLY_UPDATE_NECESSARY_DATA = false; | ||
923 | |||
924 | string sql = String.Empty; | ||
925 | if (GRID_ONLY_UPDATE_NECESSARY_DATA) | ||
926 | { | ||
927 | sql += "INSERT INTO "; | ||
928 | } | ||
929 | else | ||
930 | { | ||
931 | sql += "REPLACE INTO "; | ||
932 | } | ||
933 | |||
934 | sql += "regions (regionHandle, regionName, uuid, regionRecvKey, regionSecret, regionSendKey, regionDataURI, "; | ||
935 | sql += | ||
936 | "serverIP, serverPort, serverURI, locX, locY, locZ, eastOverrideHandle, westOverrideHandle, southOverrideHandle, northOverrideHandle, regionAssetURI, regionAssetRecvKey, "; | ||
937 | |||
938 | // part of an initial brutish effort to provide accurate information (as per the xml region spec) | ||
939 | // wrt the ownership of a given region | ||
940 | // the (very bad) assumption is that this value is being read and handled inconsistently or | ||
941 | // not at all. Current strategy is to put the code in place to support the validity of this information | ||
942 | // and to roll forward debugging any issues from that point | ||
943 | // | ||
944 | // this particular section of the mod attempts to implement the commit of a supplied value | ||
945 | // server for the UUID of the region's owner (master avatar). It consists of the addition of the column and value to the relevant sql, | ||
946 | // as well as the related parameterization | ||
947 | sql += | ||
948 | "regionAssetSendKey, regionUserURI, regionUserRecvKey, regionUserSendKey, regionMapTexture, serverHttpPort, serverRemotingPort, owner_uuid, originUUID, access) VALUES "; | ||
949 | |||
950 | sql += "(?regionHandle, ?regionName, ?uuid, ?regionRecvKey, ?regionSecret, ?regionSendKey, ?regionDataURI, "; | ||
951 | sql += | ||
952 | "?serverIP, ?serverPort, ?serverURI, ?locX, ?locY, ?locZ, ?eastOverrideHandle, ?westOverrideHandle, ?southOverrideHandle, ?northOverrideHandle, ?regionAssetURI, ?regionAssetRecvKey, "; | ||
953 | sql += | ||
954 | "?regionAssetSendKey, ?regionUserURI, ?regionUserRecvKey, ?regionUserSendKey, ?regionMapTexture, ?serverHttpPort, ?serverRemotingPort, ?owner_uuid, ?originUUID, ?access)"; | ||
955 | |||
956 | if (GRID_ONLY_UPDATE_NECESSARY_DATA) | ||
957 | { | ||
958 | sql += "ON DUPLICATE KEY UPDATE serverIP = ?serverIP, serverPort = ?serverPort, serverURI = ?serverURI, owner_uuid - ?owner_uuid;"; | ||
959 | } | ||
960 | else | ||
961 | { | ||
962 | sql += ";"; | ||
963 | } | ||
964 | |||
965 | Dictionary<string, object> parameters = new Dictionary<string, object>(); | ||
966 | |||
967 | parameters["?regionHandle"] = regiondata.regionHandle.ToString(); | ||
968 | parameters["?regionName"] = regiondata.regionName.ToString(); | ||
969 | parameters["?uuid"] = regiondata.UUID.ToString(); | ||
970 | parameters["?regionRecvKey"] = regiondata.regionRecvKey.ToString(); | ||
971 | parameters["?regionSecret"] = regiondata.regionSecret.ToString(); | ||
972 | parameters["?regionSendKey"] = regiondata.regionSendKey.ToString(); | ||
973 | parameters["?regionDataURI"] = regiondata.regionDataURI.ToString(); | ||
974 | parameters["?serverIP"] = regiondata.serverIP.ToString(); | ||
975 | parameters["?serverPort"] = regiondata.serverPort.ToString(); | ||
976 | parameters["?serverURI"] = regiondata.serverURI.ToString(); | ||
977 | parameters["?locX"] = regiondata.regionLocX.ToString(); | ||
978 | parameters["?locY"] = regiondata.regionLocY.ToString(); | ||
979 | parameters["?locZ"] = regiondata.regionLocZ.ToString(); | ||
980 | parameters["?eastOverrideHandle"] = regiondata.regionEastOverrideHandle.ToString(); | ||
981 | parameters["?westOverrideHandle"] = regiondata.regionWestOverrideHandle.ToString(); | ||
982 | parameters["?northOverrideHandle"] = regiondata.regionNorthOverrideHandle.ToString(); | ||
983 | parameters["?southOverrideHandle"] = regiondata.regionSouthOverrideHandle.ToString(); | ||
984 | parameters["?regionAssetURI"] = regiondata.regionAssetURI.ToString(); | ||
985 | parameters["?regionAssetRecvKey"] = regiondata.regionAssetRecvKey.ToString(); | ||
986 | parameters["?regionAssetSendKey"] = regiondata.regionAssetSendKey.ToString(); | ||
987 | parameters["?regionUserURI"] = regiondata.regionUserURI.ToString(); | ||
988 | parameters["?regionUserRecvKey"] = regiondata.regionUserRecvKey.ToString(); | ||
989 | parameters["?regionUserSendKey"] = regiondata.regionUserSendKey.ToString(); | ||
990 | parameters["?regionMapTexture"] = regiondata.regionMapTextureID.ToString(); | ||
991 | parameters["?serverHttpPort"] = regiondata.httpPort.ToString(); | ||
992 | parameters["?serverRemotingPort"] = regiondata.remotingPort.ToString(); | ||
993 | parameters["?owner_uuid"] = regiondata.owner_uuid.ToString(); | ||
994 | parameters["?originUUID"] = regiondata.originUUID.ToString(); | ||
995 | parameters["?access"] = regiondata.maturity.ToString(); | ||
996 | |||
997 | bool returnval = false; | ||
998 | |||
999 | try | ||
1000 | { | ||
1001 | using (MySqlConnection dbcon = new MySqlConnection(connectionString)) | ||
1002 | { | ||
1003 | dbcon.Open(); | ||
1004 | |||
1005 | IDbCommand result = Query(dbcon, sql, parameters); | ||
1006 | |||
1007 | // int x; | ||
1008 | // if ((x = result.ExecuteNonQuery()) > 0) | ||
1009 | // { | ||
1010 | // returnval = true; | ||
1011 | // } | ||
1012 | if (result.ExecuteNonQuery() > 0) | ||
1013 | { | ||
1014 | returnval = true; | ||
1015 | } | ||
1016 | result.Dispose(); | ||
1017 | } | ||
1018 | } | ||
1019 | catch (Exception e) | ||
1020 | { | ||
1021 | m_log.Error(e.ToString()); | ||
1022 | return false; | ||
1023 | } | ||
1024 | |||
1025 | return returnval; | ||
1026 | } | ||
1027 | |||
1028 | /// <summary> | ||
1029 | /// Delete a region from the database | ||
1030 | /// </summary> | ||
1031 | /// <param name="uuid">The region to delete</param> | ||
1032 | /// <returns>Success?</returns> | ||
1033 | //public bool deleteRegion(RegionProfileData regiondata) | ||
1034 | public bool deleteRegion(string uuid) | ||
1035 | { | ||
1036 | bool returnval = false; | ||
1037 | |||
1038 | string sql = "DELETE FROM regions WHERE uuid = ?uuid;"; | ||
1039 | |||
1040 | Dictionary<string, object> parameters = new Dictionary<string, object>(); | ||
1041 | |||
1042 | try | ||
1043 | { | ||
1044 | parameters["?uuid"] = uuid; | ||
1045 | |||
1046 | using (MySqlConnection dbcon = new MySqlConnection(connectionString)) | ||
1047 | { | ||
1048 | dbcon.Open(); | ||
1049 | |||
1050 | IDbCommand result = Query(dbcon, sql, parameters); | ||
1051 | |||
1052 | // int x; | ||
1053 | // if ((x = result.ExecuteNonQuery()) > 0) | ||
1054 | // { | ||
1055 | // returnval = true; | ||
1056 | // } | ||
1057 | if (result.ExecuteNonQuery() > 0) | ||
1058 | { | ||
1059 | returnval = true; | ||
1060 | } | ||
1061 | result.Dispose(); | ||
1062 | } | ||
1063 | } | ||
1064 | catch (Exception e) | ||
1065 | { | ||
1066 | m_log.Error(e.ToString()); | ||
1067 | return false; | ||
1068 | } | ||
1069 | |||
1070 | return returnval; | ||
1071 | } | ||
1072 | |||
1073 | /// <summary> | ||
1074 | /// Creates a new agent and inserts it into the database | ||
1075 | /// </summary> | ||
1076 | /// <param name="agentdata">The agent data to be inserted</param> | ||
1077 | /// <returns>Success?</returns> | ||
1078 | public bool insertAgentRow(UserAgentData agentdata) | ||
1079 | { | ||
1080 | string sql = String.Empty; | ||
1081 | sql += "REPLACE INTO "; | ||
1082 | sql += "agents (UUID, sessionID, secureSessionID, agentIP, agentPort, agentOnline, loginTime, logoutTime, currentRegion, currentHandle, currentPos, currentLookAt) VALUES "; | ||
1083 | sql += "(?UUID, ?sessionID, ?secureSessionID, ?agentIP, ?agentPort, ?agentOnline, ?loginTime, ?logoutTime, ?currentRegion, ?currentHandle, ?currentPos, ?currentLookAt);"; | ||
1084 | Dictionary<string, object> parameters = new Dictionary<string, object>(); | ||
1085 | |||
1086 | parameters["?UUID"] = agentdata.ProfileID.ToString(); | ||
1087 | parameters["?sessionID"] = agentdata.SessionID.ToString(); | ||
1088 | parameters["?secureSessionID"] = agentdata.SecureSessionID.ToString(); | ||
1089 | parameters["?agentIP"] = agentdata.AgentIP.ToString(); | ||
1090 | parameters["?agentPort"] = agentdata.AgentPort.ToString(); | ||
1091 | parameters["?agentOnline"] = (agentdata.AgentOnline == true) ? "1" : "0"; | ||
1092 | parameters["?loginTime"] = agentdata.LoginTime.ToString(); | ||
1093 | parameters["?logoutTime"] = agentdata.LogoutTime.ToString(); | ||
1094 | parameters["?currentRegion"] = agentdata.Region.ToString(); | ||
1095 | parameters["?currentHandle"] = agentdata.Handle.ToString(); | ||
1096 | parameters["?currentPos"] = "<" + (agentdata.Position.X).ToString().Replace(",", ".") + "," + (agentdata.Position.Y).ToString().Replace(",", ".") + "," + (agentdata.Position.Z).ToString().Replace(",", ".") + ">"; | ||
1097 | parameters["?currentLookAt"] = "<" + (agentdata.LookAt.X).ToString().Replace(",", ".") + "," + (agentdata.LookAt.Y).ToString().Replace(",", ".") + "," + (agentdata.LookAt.Z).ToString().Replace(",", ".") + ">"; | ||
1098 | |||
1099 | bool returnval = false; | ||
1100 | |||
1101 | try | ||
1102 | { | ||
1103 | using (MySqlConnection dbcon = new MySqlConnection(connectionString)) | ||
1104 | { | ||
1105 | dbcon.Open(); | ||
1106 | |||
1107 | IDbCommand result = Query(dbcon, sql, parameters); | ||
1108 | |||
1109 | // int x; | ||
1110 | // if ((x = result.ExecuteNonQuery()) > 0) | ||
1111 | // { | ||
1112 | // returnval = true; | ||
1113 | // } | ||
1114 | if (result.ExecuteNonQuery() > 0) | ||
1115 | { | ||
1116 | returnval = true; | ||
1117 | } | ||
1118 | result.Dispose(); | ||
1119 | } | ||
1120 | } | ||
1121 | catch (Exception e) | ||
1122 | { | ||
1123 | m_log.Error(e.ToString()); | ||
1124 | return false; | ||
1125 | } | ||
1126 | |||
1127 | return returnval; | ||
1128 | } | ||
1129 | |||
1130 | /// <summary> | ||
1131 | /// Create (or replace if existing) an avatar appearence | ||
1132 | /// </summary> | ||
1133 | /// <param name="appearance"></param> | ||
1134 | /// <returns>Succes?</returns> | ||
1135 | public bool insertAppearanceRow(AvatarAppearance appearance) | ||
1136 | { | ||
1137 | string sql = String.Empty; | ||
1138 | sql += "REPLACE INTO "; | ||
1139 | sql += "avatarappearance (owner, serial, visual_params, texture, avatar_height, "; | ||
1140 | sql += "body_item, body_asset, skin_item, skin_asset, hair_item, hair_asset, eyes_item, eyes_asset, "; | ||
1141 | sql += "shirt_item, shirt_asset, pants_item, pants_asset, shoes_item, shoes_asset, socks_item, socks_asset, "; | ||
1142 | sql += "jacket_item, jacket_asset, gloves_item, gloves_asset, undershirt_item, undershirt_asset, underpants_item, underpants_asset, "; | ||
1143 | sql += "skirt_item, skirt_asset) values ("; | ||
1144 | sql += "?owner, ?serial, ?visual_params, ?texture, ?avatar_height, "; | ||
1145 | sql += "?body_item, ?body_asset, ?skin_item, ?skin_asset, ?hair_item, ?hair_asset, ?eyes_item, ?eyes_asset, "; | ||
1146 | sql += "?shirt_item, ?shirt_asset, ?pants_item, ?pants_asset, ?shoes_item, ?shoes_asset, ?socks_item, ?socks_asset, "; | ||
1147 | sql += "?jacket_item, ?jacket_asset, ?gloves_item, ?gloves_asset, ?undershirt_item, ?undershirt_asset, ?underpants_item, ?underpants_asset, "; | ||
1148 | sql += "?skirt_item, ?skirt_asset)"; | ||
1149 | |||
1150 | bool returnval = false; | ||
1151 | |||
1152 | // we want to send in byte data, which means we can't just pass down strings | ||
1153 | try | ||
1154 | { | ||
1155 | using (MySqlConnection dbcon = new MySqlConnection(connectionString)) | ||
1156 | { | ||
1157 | dbcon.Open(); | ||
1158 | |||
1159 | using (MySqlCommand cmd = (MySqlCommand)dbcon.CreateCommand()) | ||
1160 | { | ||
1161 | cmd.CommandText = sql; | ||
1162 | cmd.Parameters.AddWithValue("?owner", appearance.Owner.ToString()); | ||
1163 | cmd.Parameters.AddWithValue("?serial", appearance.Serial); | ||
1164 | cmd.Parameters.AddWithValue("?visual_params", appearance.VisualParams); | ||
1165 | cmd.Parameters.AddWithValue("?texture", appearance.Texture.GetBytes()); | ||
1166 | cmd.Parameters.AddWithValue("?avatar_height", appearance.AvatarHeight); | ||
1167 | cmd.Parameters.AddWithValue("?body_item", appearance.BodyItem.ToString()); | ||
1168 | cmd.Parameters.AddWithValue("?body_asset", appearance.BodyAsset.ToString()); | ||
1169 | cmd.Parameters.AddWithValue("?skin_item", appearance.SkinItem.ToString()); | ||
1170 | cmd.Parameters.AddWithValue("?skin_asset", appearance.SkinAsset.ToString()); | ||
1171 | cmd.Parameters.AddWithValue("?hair_item", appearance.HairItem.ToString()); | ||
1172 | cmd.Parameters.AddWithValue("?hair_asset", appearance.HairAsset.ToString()); | ||
1173 | cmd.Parameters.AddWithValue("?eyes_item", appearance.EyesItem.ToString()); | ||
1174 | cmd.Parameters.AddWithValue("?eyes_asset", appearance.EyesAsset.ToString()); | ||
1175 | cmd.Parameters.AddWithValue("?shirt_item", appearance.ShirtItem.ToString()); | ||
1176 | cmd.Parameters.AddWithValue("?shirt_asset", appearance.ShirtAsset.ToString()); | ||
1177 | cmd.Parameters.AddWithValue("?pants_item", appearance.PantsItem.ToString()); | ||
1178 | cmd.Parameters.AddWithValue("?pants_asset", appearance.PantsAsset.ToString()); | ||
1179 | cmd.Parameters.AddWithValue("?shoes_item", appearance.ShoesItem.ToString()); | ||
1180 | cmd.Parameters.AddWithValue("?shoes_asset", appearance.ShoesAsset.ToString()); | ||
1181 | cmd.Parameters.AddWithValue("?socks_item", appearance.SocksItem.ToString()); | ||
1182 | cmd.Parameters.AddWithValue("?socks_asset", appearance.SocksAsset.ToString()); | ||
1183 | cmd.Parameters.AddWithValue("?jacket_item", appearance.JacketItem.ToString()); | ||
1184 | cmd.Parameters.AddWithValue("?jacket_asset", appearance.JacketAsset.ToString()); | ||
1185 | cmd.Parameters.AddWithValue("?gloves_item", appearance.GlovesItem.ToString()); | ||
1186 | cmd.Parameters.AddWithValue("?gloves_asset", appearance.GlovesAsset.ToString()); | ||
1187 | cmd.Parameters.AddWithValue("?undershirt_item", appearance.UnderShirtItem.ToString()); | ||
1188 | cmd.Parameters.AddWithValue("?undershirt_asset", appearance.UnderShirtAsset.ToString()); | ||
1189 | cmd.Parameters.AddWithValue("?underpants_item", appearance.UnderPantsItem.ToString()); | ||
1190 | cmd.Parameters.AddWithValue("?underpants_asset", appearance.UnderPantsAsset.ToString()); | ||
1191 | cmd.Parameters.AddWithValue("?skirt_item", appearance.SkirtItem.ToString()); | ||
1192 | cmd.Parameters.AddWithValue("?skirt_asset", appearance.SkirtAsset.ToString()); | ||
1193 | |||
1194 | if (cmd.ExecuteNonQuery() > 0) | ||
1195 | returnval = true; | ||
1196 | } | ||
1197 | } | ||
1198 | } | ||
1199 | catch (Exception e) | ||
1200 | { | ||
1201 | m_log.Error(e.ToString()); | ||
1202 | return false; | ||
1203 | } | ||
1204 | |||
1205 | return returnval; | ||
1206 | |||
1207 | } | ||
1208 | |||
1209 | public void writeAttachments(UUID agentID, Hashtable data) | ||
1210 | { | ||
1211 | string sql = "delete from avatarattachments where UUID = ?uuid"; | ||
1212 | |||
1213 | using (MySqlConnection dbcon = new MySqlConnection(connectionString)) | ||
1214 | { | ||
1215 | dbcon.Open(); | ||
1216 | |||
1217 | MySqlCommand cmd = (MySqlCommand)dbcon.CreateCommand(); | ||
1218 | cmd.CommandText = sql; | ||
1219 | cmd.Parameters.AddWithValue("?uuid", agentID.ToString()); | ||
1220 | |||
1221 | cmd.ExecuteNonQuery(); | ||
1222 | |||
1223 | if (data == null) | ||
1224 | return; | ||
1225 | |||
1226 | sql = "insert into avatarattachments (UUID, attachpoint, item, asset) values (?uuid, ?attachpoint, ?item, ?asset)"; | ||
1227 | |||
1228 | cmd = (MySqlCommand)dbcon.CreateCommand(); | ||
1229 | cmd.CommandText = sql; | ||
1230 | |||
1231 | foreach (DictionaryEntry e in data) | ||
1232 | { | ||
1233 | int attachpoint = Convert.ToInt32(e.Key); | ||
1234 | |||
1235 | Hashtable item = (Hashtable)e.Value; | ||
1236 | |||
1237 | cmd.Parameters.Clear(); | ||
1238 | cmd.Parameters.AddWithValue("?uuid", agentID.ToString()); | ||
1239 | cmd.Parameters.AddWithValue("?attachpoint", attachpoint); | ||
1240 | cmd.Parameters.AddWithValue("?item", item["item"]); | ||
1241 | cmd.Parameters.AddWithValue("?asset", item["asset"]); | ||
1242 | |||
1243 | cmd.ExecuteNonQuery(); | ||
1244 | } | ||
1245 | } | ||
1246 | } | ||
1247 | } | ||
1248 | } | ||
diff --git a/OpenSim/Data/MySQL/MySQLSuperManager.cs b/OpenSim/Data/MySQL/MySQLSuperManager.cs deleted file mode 100644 index c579432..0000000 --- a/OpenSim/Data/MySQL/MySQLSuperManager.cs +++ /dev/null | |||
@@ -1,52 +0,0 @@ | |||
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.Threading; | ||
29 | |||
30 | namespace OpenSim.Data.MySQL | ||
31 | { | ||
32 | public class MySQLSuperManager | ||
33 | { | ||
34 | public bool Locked; | ||
35 | private readonly Mutex m_lock = new Mutex(false); | ||
36 | public MySQLManager Manager; | ||
37 | public string Running; | ||
38 | |||
39 | public void GetLock() | ||
40 | { | ||
41 | Locked = true; | ||
42 | m_lock.WaitOne(); | ||
43 | } | ||
44 | |||
45 | public void Release() | ||
46 | { | ||
47 | m_lock.ReleaseMutex(); | ||
48 | Locked = false; | ||
49 | } | ||
50 | |||
51 | } | ||
52 | } | ||
diff --git a/OpenSim/Data/MySQL/MySQLUserData.cs b/OpenSim/Data/MySQL/MySQLUserData.cs deleted file mode 100644 index 0a9d2e3..0000000 --- a/OpenSim/Data/MySQL/MySQLUserData.cs +++ /dev/null | |||
@@ -1,766 +0,0 @@ | |||
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.Data; | ||
32 | using System.Reflection; | ||
33 | using System.Text.RegularExpressions; | ||
34 | using System.Threading; | ||
35 | using log4net; | ||
36 | using MySql.Data.MySqlClient; | ||
37 | using OpenMetaverse; | ||
38 | using OpenSim.Framework; | ||
39 | |||
40 | namespace OpenSim.Data.MySQL | ||
41 | { | ||
42 | /// <summary> | ||
43 | /// A database interface class to a user profile storage system | ||
44 | /// </summary> | ||
45 | public class MySQLUserData : UserDataBase | ||
46 | { | ||
47 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
48 | |||
49 | private MySQLManager m_database; | ||
50 | private string m_connectionString; | ||
51 | private object m_dbLock = new object(); | ||
52 | |||
53 | public int m_maxConnections = 10; | ||
54 | public int m_lastConnect; | ||
55 | |||
56 | private string m_agentsTableName = "agents"; | ||
57 | private string m_usersTableName = "users"; | ||
58 | private string m_userFriendsTableName = "userfriends"; | ||
59 | private string m_appearanceTableName = "avatarappearance"; | ||
60 | private string m_attachmentsTableName = "avatarattachments"; | ||
61 | |||
62 | public override void Initialise() | ||
63 | { | ||
64 | m_log.Info("[MySQLUserData]: " + Name + " cannot be default-initialized!"); | ||
65 | throw new PluginNotInitialisedException(Name); | ||
66 | } | ||
67 | |||
68 | /// <summary> | ||
69 | /// Initialise User Interface | ||
70 | /// Loads and initialises the MySQL storage plugin | ||
71 | /// Warns and uses the obsolete mysql_connection.ini if connect string is empty. | ||
72 | /// Checks for migration | ||
73 | /// </summary> | ||
74 | /// <param name="connect">connect string.</param> | ||
75 | public override void Initialise(string connect) | ||
76 | { | ||
77 | m_connectionString = connect; | ||
78 | m_database = new MySQLManager(connect); | ||
79 | |||
80 | // This actually does the roll forward assembly stuff | ||
81 | Assembly assem = GetType().Assembly; | ||
82 | |||
83 | using (MySql.Data.MySqlClient.MySqlConnection dbcon = new MySql.Data.MySqlClient.MySqlConnection(m_connectionString)) | ||
84 | { | ||
85 | dbcon.Open(); | ||
86 | Migration m = new Migration(dbcon, assem, "UserStore"); | ||
87 | m.Update(); | ||
88 | } | ||
89 | } | ||
90 | |||
91 | public override void Dispose() | ||
92 | { | ||
93 | } | ||
94 | |||
95 | // see IUserDataPlugin | ||
96 | public override UserProfileData GetUserByName(string user, string last) | ||
97 | { | ||
98 | try | ||
99 | { | ||
100 | Dictionary<string, object> param = new Dictionary<string, object>(); | ||
101 | param["?first"] = user; | ||
102 | param["?second"] = last; | ||
103 | |||
104 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | ||
105 | { | ||
106 | dbcon.Open(); | ||
107 | |||
108 | using (IDbCommand result = m_database.Query(dbcon, | ||
109 | "SELECT * FROM " + m_usersTableName + " WHERE username = ?first AND lastname = ?second", param)) | ||
110 | { | ||
111 | using (IDataReader reader = result.ExecuteReader()) | ||
112 | { | ||
113 | UserProfileData row = m_database.readUserRow(reader); | ||
114 | return row; | ||
115 | } | ||
116 | } | ||
117 | } | ||
118 | } | ||
119 | catch (Exception e) | ||
120 | { | ||
121 | m_log.Error(e.Message, e); | ||
122 | return null; | ||
123 | } | ||
124 | } | ||
125 | |||
126 | #region User Friends List Data | ||
127 | |||
128 | public override void AddNewUserFriend(UUID friendlistowner, UUID friend, uint perms) | ||
129 | { | ||
130 | int dtvalue = Util.UnixTimeSinceEpoch(); | ||
131 | |||
132 | Dictionary<string, object> param = new Dictionary<string, object>(); | ||
133 | param["?ownerID"] = friendlistowner.ToString(); | ||
134 | param["?friendID"] = friend.ToString(); | ||
135 | param["?friendPerms"] = perms.ToString(); | ||
136 | param["?datetimestamp"] = dtvalue.ToString(); | ||
137 | |||
138 | try | ||
139 | { | ||
140 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | ||
141 | { | ||
142 | dbcon.Open(); | ||
143 | |||
144 | using (IDbCommand adder = m_database.Query(dbcon, | ||
145 | "INSERT INTO `" + m_userFriendsTableName + "` " + | ||
146 | "(`ownerID`,`friendID`,`friendPerms`,`datetimestamp`) " + | ||
147 | "VALUES " + | ||
148 | "(?ownerID,?friendID,?friendPerms,?datetimestamp)", | ||
149 | param)) | ||
150 | { | ||
151 | adder.ExecuteNonQuery(); | ||
152 | } | ||
153 | |||
154 | using (IDbCommand adder = m_database.Query(dbcon, | ||
155 | "INSERT INTO `" + m_userFriendsTableName + "` " + | ||
156 | "(`ownerID`,`friendID`,`friendPerms`,`datetimestamp`) " + | ||
157 | "VALUES " + | ||
158 | "(?friendID,?ownerID,?friendPerms,?datetimestamp)", | ||
159 | param)) | ||
160 | { | ||
161 | adder.ExecuteNonQuery(); | ||
162 | } | ||
163 | } | ||
164 | } | ||
165 | catch (Exception e) | ||
166 | { | ||
167 | m_log.Error(e.Message, e); | ||
168 | return; | ||
169 | } | ||
170 | } | ||
171 | |||
172 | public override void RemoveUserFriend(UUID friendlistowner, UUID friend) | ||
173 | { | ||
174 | Dictionary<string, object> param = new Dictionary<string, object>(); | ||
175 | param["?ownerID"] = friendlistowner.ToString(); | ||
176 | param["?friendID"] = friend.ToString(); | ||
177 | |||
178 | try | ||
179 | { | ||
180 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | ||
181 | { | ||
182 | dbcon.Open(); | ||
183 | |||
184 | using (IDbCommand updater = m_database.Query(dbcon, | ||
185 | "delete from " + m_userFriendsTableName + " where ownerID = ?ownerID and friendID = ?friendID", | ||
186 | param)) | ||
187 | { | ||
188 | updater.ExecuteNonQuery(); | ||
189 | } | ||
190 | |||
191 | using (IDbCommand updater = m_database.Query(dbcon, | ||
192 | "delete from " + m_userFriendsTableName + " where ownerID = ?friendID and friendID = ?ownerID", | ||
193 | param)) | ||
194 | { | ||
195 | updater.ExecuteNonQuery(); | ||
196 | } | ||
197 | } | ||
198 | } | ||
199 | catch (Exception e) | ||
200 | { | ||
201 | m_log.Error(e.Message, e); | ||
202 | return; | ||
203 | } | ||
204 | } | ||
205 | |||
206 | public override void UpdateUserFriendPerms(UUID friendlistowner, UUID friend, uint perms) | ||
207 | { | ||
208 | Dictionary<string, object> param = new Dictionary<string, object>(); | ||
209 | param["?ownerID"] = friendlistowner.ToString(); | ||
210 | param["?friendID"] = friend.ToString(); | ||
211 | param["?friendPerms"] = perms.ToString(); | ||
212 | |||
213 | try | ||
214 | { | ||
215 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | ||
216 | { | ||
217 | dbcon.Open(); | ||
218 | |||
219 | using (IDbCommand updater = m_database.Query(dbcon, | ||
220 | "update " + m_userFriendsTableName + | ||
221 | " SET friendPerms = ?friendPerms " + | ||
222 | "where ownerID = ?ownerID and friendID = ?friendID", | ||
223 | param)) | ||
224 | { | ||
225 | updater.ExecuteNonQuery(); | ||
226 | } | ||
227 | } | ||
228 | } | ||
229 | catch (Exception e) | ||
230 | { | ||
231 | m_log.Error(e.Message, e); | ||
232 | return; | ||
233 | } | ||
234 | } | ||
235 | |||
236 | public override List<FriendListItem> GetUserFriendList(UUID friendlistowner) | ||
237 | { | ||
238 | List<FriendListItem> Lfli = new List<FriendListItem>(); | ||
239 | |||
240 | Dictionary<string, object> param = new Dictionary<string, object>(); | ||
241 | param["?ownerID"] = friendlistowner.ToString(); | ||
242 | |||
243 | try | ||
244 | { | ||
245 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | ||
246 | { | ||
247 | dbcon.Open(); | ||
248 | |||
249 | //Left Join userfriends to itself | ||
250 | using (IDbCommand result = m_database.Query(dbcon, | ||
251 | "select a.ownerID,a.friendID,a.friendPerms,b.friendPerms as ownerperms from " + | ||
252 | m_userFriendsTableName + " as a, " + m_userFriendsTableName + " as b" + | ||
253 | " where a.ownerID = ?ownerID and b.ownerID = a.friendID and b.friendID = a.ownerID", | ||
254 | param)) | ||
255 | { | ||
256 | using (IDataReader reader = result.ExecuteReader()) | ||
257 | { | ||
258 | while (reader.Read()) | ||
259 | { | ||
260 | FriendListItem fli = new FriendListItem(); | ||
261 | fli.FriendListOwner = new UUID((string)reader["ownerID"]); | ||
262 | fli.Friend = new UUID((string)reader["friendID"]); | ||
263 | fli.FriendPerms = (uint)Convert.ToInt32(reader["friendPerms"]); | ||
264 | |||
265 | // This is not a real column in the database table, it's a joined column from the opposite record | ||
266 | fli.FriendListOwnerPerms = (uint)Convert.ToInt32(reader["ownerperms"]); | ||
267 | |||
268 | Lfli.Add(fli); | ||
269 | } | ||
270 | } | ||
271 | } | ||
272 | } | ||
273 | } | ||
274 | catch (Exception e) | ||
275 | { | ||
276 | m_log.Error(e.Message, e); | ||
277 | return Lfli; | ||
278 | } | ||
279 | |||
280 | return Lfli; | ||
281 | } | ||
282 | |||
283 | override public Dictionary<UUID, FriendRegionInfo> GetFriendRegionInfos (List<UUID> uuids) | ||
284 | { | ||
285 | Dictionary<UUID, FriendRegionInfo> infos = new Dictionary<UUID,FriendRegionInfo>(); | ||
286 | |||
287 | try | ||
288 | { | ||
289 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | ||
290 | { | ||
291 | dbcon.Open(); | ||
292 | |||
293 | foreach (UUID uuid in uuids) | ||
294 | { | ||
295 | Dictionary<string, object> param = new Dictionary<string, object>(); | ||
296 | param["?uuid"] = uuid.ToString(); | ||
297 | |||
298 | using (IDbCommand result = m_database.Query(dbcon, "select agentOnline,currentHandle from " + m_agentsTableName + | ||
299 | " where UUID = ?uuid", param)) | ||
300 | { | ||
301 | using (IDataReader reader = result.ExecuteReader()) | ||
302 | { | ||
303 | while (reader.Read()) | ||
304 | { | ||
305 | FriendRegionInfo fri = new FriendRegionInfo(); | ||
306 | fri.isOnline = (sbyte)reader["agentOnline"] != 0; | ||
307 | fri.regionHandle = (ulong)reader["currentHandle"]; | ||
308 | |||
309 | infos[uuid] = fri; | ||
310 | } | ||
311 | } | ||
312 | } | ||
313 | } | ||
314 | } | ||
315 | } | ||
316 | catch (Exception e) | ||
317 | { | ||
318 | m_log.Warn("[MYSQL]: Got exception on trying to find friends regions:", e); | ||
319 | m_log.Error(e.Message, e); | ||
320 | } | ||
321 | |||
322 | return infos; | ||
323 | } | ||
324 | |||
325 | #endregion | ||
326 | |||
327 | public override List<AvatarPickerAvatar> GeneratePickerResults(UUID queryID, string query) | ||
328 | { | ||
329 | List<AvatarPickerAvatar> returnlist = new List<AvatarPickerAvatar>(); | ||
330 | |||
331 | Regex objAlphaNumericPattern = new Regex("[^a-zA-Z0-9]"); | ||
332 | |||
333 | string[] querysplit; | ||
334 | querysplit = query.Split(' '); | ||
335 | if (querysplit.Length > 1 && querysplit[1].Trim() != String.Empty) | ||
336 | { | ||
337 | Dictionary<string, object> param = new Dictionary<string, object>(); | ||
338 | param["?first"] = objAlphaNumericPattern.Replace(querysplit[0], String.Empty) + "%"; | ||
339 | param["?second"] = objAlphaNumericPattern.Replace(querysplit[1], String.Empty) + "%"; | ||
340 | |||
341 | try | ||
342 | { | ||
343 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | ||
344 | { | ||
345 | dbcon.Open(); | ||
346 | |||
347 | using (IDbCommand result = m_database.Query(dbcon, | ||
348 | "SELECT UUID,username,lastname FROM " + m_usersTableName + | ||
349 | " WHERE username like ?first AND lastname like ?second LIMIT 100", | ||
350 | param)) | ||
351 | { | ||
352 | using (IDataReader reader = result.ExecuteReader()) | ||
353 | { | ||
354 | while (reader.Read()) | ||
355 | { | ||
356 | AvatarPickerAvatar user = new AvatarPickerAvatar(); | ||
357 | user.AvatarID = new UUID((string)reader["UUID"]); | ||
358 | user.firstName = (string)reader["username"]; | ||
359 | user.lastName = (string)reader["lastname"]; | ||
360 | returnlist.Add(user); | ||
361 | } | ||
362 | } | ||
363 | } | ||
364 | } | ||
365 | } | ||
366 | catch (Exception e) | ||
367 | { | ||
368 | m_log.Error(e.Message, e); | ||
369 | return returnlist; | ||
370 | } | ||
371 | } | ||
372 | else | ||
373 | { | ||
374 | try | ||
375 | { | ||
376 | Dictionary<string, object> param = new Dictionary<string, object>(); | ||
377 | param["?first"] = objAlphaNumericPattern.Replace(querysplit[0], String.Empty) + "%"; | ||
378 | |||
379 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | ||
380 | { | ||
381 | dbcon.Open(); | ||
382 | |||
383 | using (IDbCommand result = m_database.Query(dbcon, | ||
384 | "SELECT UUID,username,lastname FROM " + m_usersTableName + | ||
385 | " WHERE username like ?first OR lastname like ?first LIMIT 100", | ||
386 | param)) | ||
387 | { | ||
388 | using (IDataReader reader = result.ExecuteReader()) | ||
389 | { | ||
390 | while (reader.Read()) | ||
391 | { | ||
392 | AvatarPickerAvatar user = new AvatarPickerAvatar(); | ||
393 | user.AvatarID = new UUID((string)reader["UUID"]); | ||
394 | user.firstName = (string)reader["username"]; | ||
395 | user.lastName = (string)reader["lastname"]; | ||
396 | returnlist.Add(user); | ||
397 | } | ||
398 | } | ||
399 | } | ||
400 | } | ||
401 | } | ||
402 | catch (Exception e) | ||
403 | { | ||
404 | m_log.Error(e.Message, e); | ||
405 | return returnlist; | ||
406 | } | ||
407 | } | ||
408 | return returnlist; | ||
409 | } | ||
410 | |||
411 | /// <summary> | ||
412 | /// See IUserDataPlugin | ||
413 | /// </summary> | ||
414 | /// <param name="uuid">User UUID</param> | ||
415 | /// <returns>User profile data</returns> | ||
416 | public override UserProfileData GetUserByUUID(UUID uuid) | ||
417 | { | ||
418 | try | ||
419 | { | ||
420 | Dictionary<string, object> param = new Dictionary<string, object>(); | ||
421 | param["?uuid"] = uuid.ToString(); | ||
422 | |||
423 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | ||
424 | { | ||
425 | dbcon.Open(); | ||
426 | |||
427 | using (IDbCommand result = m_database.Query(dbcon, "SELECT * FROM " + m_usersTableName + " WHERE UUID = ?uuid", param)) | ||
428 | { | ||
429 | using (IDataReader reader = result.ExecuteReader()) | ||
430 | { | ||
431 | UserProfileData row = m_database.readUserRow(reader); | ||
432 | return row; | ||
433 | } | ||
434 | } | ||
435 | } | ||
436 | } | ||
437 | catch (Exception e) | ||
438 | { | ||
439 | m_log.Error(e.Message, e); | ||
440 | return null; | ||
441 | } | ||
442 | } | ||
443 | |||
444 | /// <summary> | ||
445 | /// Returns a user session searching by name | ||
446 | /// </summary> | ||
447 | /// <param name="name">The account name : "Username Lastname"</param> | ||
448 | /// <returns>The users session</returns> | ||
449 | public override UserAgentData GetAgentByName(string name) | ||
450 | { | ||
451 | return GetAgentByName(name.Split(' ')[0], name.Split(' ')[1]); | ||
452 | } | ||
453 | |||
454 | /// <summary> | ||
455 | /// Returns a user session by account name | ||
456 | /// </summary> | ||
457 | /// <param name="user">First part of the users account name</param> | ||
458 | /// <param name="last">Second part of the users account name</param> | ||
459 | /// <returns>The users session</returns> | ||
460 | public override UserAgentData GetAgentByName(string user, string last) | ||
461 | { | ||
462 | UserProfileData profile = GetUserByName(user, last); | ||
463 | return GetAgentByUUID(profile.ID); | ||
464 | } | ||
465 | |||
466 | /// <summary> | ||
467 | /// </summary> | ||
468 | /// <param name="AgentID"></param> | ||
469 | /// <param name="WebLoginKey"></param> | ||
470 | /// <remarks>is it still used ?</remarks> | ||
471 | public override void StoreWebLoginKey(UUID AgentID, UUID WebLoginKey) | ||
472 | { | ||
473 | Dictionary<string, string> param = new Dictionary<string, string>(); | ||
474 | param["?UUID"] = AgentID.ToString(); | ||
475 | param["?webLoginKey"] = WebLoginKey.ToString(); | ||
476 | |||
477 | try | ||
478 | { | ||
479 | m_database.ExecuteParameterizedSql( | ||
480 | "update " + m_usersTableName + " SET webLoginKey = ?webLoginKey " + | ||
481 | "where UUID = ?UUID", | ||
482 | param); | ||
483 | } | ||
484 | catch (Exception e) | ||
485 | { | ||
486 | m_log.Error(e.Message, e); | ||
487 | return; | ||
488 | } | ||
489 | } | ||
490 | |||
491 | /// <summary> | ||
492 | /// Returns an agent session by account UUID | ||
493 | /// </summary> | ||
494 | /// <param name="uuid">The accounts UUID</param> | ||
495 | /// <returns>The users session</returns> | ||
496 | public override UserAgentData GetAgentByUUID(UUID uuid) | ||
497 | { | ||
498 | try | ||
499 | { | ||
500 | Dictionary<string, object> param = new Dictionary<string, object>(); | ||
501 | param["?uuid"] = uuid.ToString(); | ||
502 | |||
503 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | ||
504 | { | ||
505 | dbcon.Open(); | ||
506 | |||
507 | using (IDbCommand result = m_database.Query(dbcon, "SELECT * FROM " + m_agentsTableName + " WHERE UUID = ?uuid", param)) | ||
508 | { | ||
509 | using (IDataReader reader = result.ExecuteReader()) | ||
510 | { | ||
511 | UserAgentData row = m_database.readAgentRow(reader); | ||
512 | return row; | ||
513 | } | ||
514 | } | ||
515 | } | ||
516 | } | ||
517 | catch (Exception e) | ||
518 | { | ||
519 | m_log.Error(e.Message, e); | ||
520 | return null; | ||
521 | } | ||
522 | } | ||
523 | |||
524 | /// <summary> | ||
525 | /// Creates a new users profile | ||
526 | /// </summary> | ||
527 | /// <param name="user">The user profile to create</param> | ||
528 | public override void AddNewUserProfile(UserProfileData user) | ||
529 | { | ||
530 | UUID zero = UUID.Zero; | ||
531 | if (user.ID == zero) | ||
532 | { | ||
533 | return; | ||
534 | } | ||
535 | |||
536 | try | ||
537 | { | ||
538 | m_database.insertUserRow( | ||
539 | user.ID, user.FirstName, user.SurName, user.Email, user.PasswordHash, user.PasswordSalt, | ||
540 | user.HomeRegion, user.HomeRegionID, user.HomeLocation.X, user.HomeLocation.Y, | ||
541 | user.HomeLocation.Z, | ||
542 | user.HomeLookAt.X, user.HomeLookAt.Y, user.HomeLookAt.Z, user.Created, | ||
543 | user.LastLogin, user.UserInventoryURI, user.UserAssetURI, | ||
544 | user.CanDoMask, user.WantDoMask, | ||
545 | user.AboutText, user.FirstLifeAboutText, user.Image, | ||
546 | user.FirstLifeImage, user.WebLoginKey, user.UserFlags, user.GodLevel, user.CustomType, user.Partner); | ||
547 | } | ||
548 | catch (Exception e) | ||
549 | { | ||
550 | m_log.Error(e.Message, e); | ||
551 | } | ||
552 | } | ||
553 | |||
554 | /// <summary> | ||
555 | /// Creates a new agent | ||
556 | /// </summary> | ||
557 | /// <param name="agent">The agent to create</param> | ||
558 | public override void AddNewUserAgent(UserAgentData agent) | ||
559 | { | ||
560 | UUID zero = UUID.Zero; | ||
561 | if (agent.ProfileID == zero || agent.SessionID == zero) | ||
562 | return; | ||
563 | |||
564 | try | ||
565 | { | ||
566 | m_database.insertAgentRow(agent); | ||
567 | } | ||
568 | catch (Exception e) | ||
569 | { | ||
570 | m_log.Error(e.Message, e); | ||
571 | } | ||
572 | } | ||
573 | |||
574 | /// <summary> | ||
575 | /// Updates a user profile stored in the DB | ||
576 | /// </summary> | ||
577 | /// <param name="user">The profile data to use to update the DB</param> | ||
578 | public override bool UpdateUserProfile(UserProfileData user) | ||
579 | { | ||
580 | try | ||
581 | { | ||
582 | m_database.updateUserRow( | ||
583 | user.ID, user.FirstName, user.SurName, user.Email, user.PasswordHash, user.PasswordSalt, | ||
584 | user.HomeRegion, user.HomeRegionID, user.HomeLocation.X, user.HomeLocation.Y, | ||
585 | user.HomeLocation.Z, user.HomeLookAt.X, | ||
586 | user.HomeLookAt.Y, user.HomeLookAt.Z, user.Created, user.LastLogin, | ||
587 | user.UserInventoryURI, | ||
588 | user.UserAssetURI, user.CanDoMask, user.WantDoMask, user.AboutText, | ||
589 | user.FirstLifeAboutText, user.Image, user.FirstLifeImage, user.WebLoginKey, | ||
590 | user.UserFlags, user.GodLevel, user.CustomType, user.Partner); | ||
591 | |||
592 | return true; | ||
593 | } | ||
594 | catch | ||
595 | { | ||
596 | return false; | ||
597 | } | ||
598 | } | ||
599 | |||
600 | /// <summary> | ||
601 | /// Performs a money transfer request between two accounts | ||
602 | /// </summary> | ||
603 | /// <param name="from">The senders account ID</param> | ||
604 | /// <param name="to">The receivers account ID</param> | ||
605 | /// <param name="amount">The amount to transfer</param> | ||
606 | /// <returns>Success?</returns> | ||
607 | public override bool MoneyTransferRequest(UUID from, UUID to, uint amount) | ||
608 | { | ||
609 | return false; | ||
610 | } | ||
611 | |||
612 | /// <summary> | ||
613 | /// Performs an inventory transfer request between two accounts | ||
614 | /// </summary> | ||
615 | /// <remarks>TODO: Move to inventory server</remarks> | ||
616 | /// <param name="from">The senders account ID</param> | ||
617 | /// <param name="to">The receivers account ID</param> | ||
618 | /// <param name="item">The item to transfer</param> | ||
619 | /// <returns>Success?</returns> | ||
620 | public override bool InventoryTransferRequest(UUID from, UUID to, UUID item) | ||
621 | { | ||
622 | return false; | ||
623 | } | ||
624 | |||
625 | public override AvatarAppearance GetUserAppearance(UUID user) | ||
626 | { | ||
627 | try | ||
628 | { | ||
629 | Dictionary<string, object> param = new Dictionary<string, object>(); | ||
630 | param["?owner"] = user.ToString(); | ||
631 | |||
632 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | ||
633 | { | ||
634 | dbcon.Open(); | ||
635 | |||
636 | using (IDbCommand result = m_database.Query(dbcon, "SELECT * FROM " + m_appearanceTableName + " WHERE owner = ?owner", param)) | ||
637 | { | ||
638 | using (IDataReader reader = result.ExecuteReader()) | ||
639 | { | ||
640 | AvatarAppearance appearance = m_database.readAppearanceRow(reader); | ||
641 | |||
642 | if (appearance == null) | ||
643 | { | ||
644 | m_log.WarnFormat("[USER DB] No appearance found for user {0}", user.ToString()); | ||
645 | return null; | ||
646 | } | ||
647 | else | ||
648 | { | ||
649 | appearance.SetAttachments(GetUserAttachments(user)); | ||
650 | return appearance; | ||
651 | } | ||
652 | } | ||
653 | } | ||
654 | } | ||
655 | } | ||
656 | catch (Exception e) | ||
657 | { | ||
658 | m_log.Error(e.Message, e); | ||
659 | return null; | ||
660 | } | ||
661 | } | ||
662 | |||
663 | /// <summary> | ||
664 | /// Updates an avatar appearence | ||
665 | /// </summary> | ||
666 | /// <param name="user">The user UUID</param> | ||
667 | /// <param name="appearance">The avatar appearance</param> | ||
668 | // override | ||
669 | public override void UpdateUserAppearance(UUID user, AvatarAppearance appearance) | ||
670 | { | ||
671 | try | ||
672 | { | ||
673 | appearance.Owner = user; | ||
674 | m_database.insertAppearanceRow(appearance); | ||
675 | |||
676 | UpdateUserAttachments(user, appearance.GetAttachments()); | ||
677 | } | ||
678 | catch (Exception e) | ||
679 | { | ||
680 | m_log.Error(e.Message, e); | ||
681 | } | ||
682 | } | ||
683 | |||
684 | /// <summary> | ||
685 | /// Database provider name | ||
686 | /// </summary> | ||
687 | /// <returns>Provider name</returns> | ||
688 | public override string Name | ||
689 | { | ||
690 | get { return "MySQL Userdata Interface"; } | ||
691 | } | ||
692 | |||
693 | /// <summary> | ||
694 | /// Database provider version | ||
695 | /// </summary> | ||
696 | /// <returns>provider version</returns> | ||
697 | public override string Version | ||
698 | { | ||
699 | get { return "0.1"; } | ||
700 | } | ||
701 | |||
702 | public Hashtable GetUserAttachments(UUID agentID) | ||
703 | { | ||
704 | Dictionary<string, object> param = new Dictionary<string, object>(); | ||
705 | param["?uuid"] = agentID.ToString(); | ||
706 | |||
707 | try | ||
708 | { | ||
709 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | ||
710 | { | ||
711 | dbcon.Open(); | ||
712 | |||
713 | using (IDbCommand result = m_database.Query(dbcon, | ||
714 | "SELECT attachpoint, item, asset from " + m_attachmentsTableName + " WHERE UUID = ?uuid", param)) | ||
715 | { | ||
716 | using (IDataReader reader = result.ExecuteReader()) | ||
717 | { | ||
718 | Hashtable ret = m_database.readAttachments(reader); | ||
719 | return ret; | ||
720 | } | ||
721 | } | ||
722 | } | ||
723 | } | ||
724 | catch (Exception e) | ||
725 | { | ||
726 | m_log.Error(e.Message, e); | ||
727 | return null; | ||
728 | } | ||
729 | } | ||
730 | |||
731 | public void UpdateUserAttachments(UUID agentID, Hashtable data) | ||
732 | { | ||
733 | m_database.writeAttachments(agentID, data); | ||
734 | } | ||
735 | |||
736 | public override void ResetAttachments(UUID userID) | ||
737 | { | ||
738 | Dictionary<string, string> param = new Dictionary<string, string>(); | ||
739 | param["?uuid"] = userID.ToString(); | ||
740 | |||
741 | m_database.ExecuteParameterizedSql( | ||
742 | "UPDATE " + m_attachmentsTableName + | ||
743 | " SET asset = '00000000-0000-0000-0000-000000000000' WHERE UUID = ?uuid", | ||
744 | param); | ||
745 | } | ||
746 | |||
747 | public override void LogoutUsers(UUID regionID) | ||
748 | { | ||
749 | Dictionary<string, string> param = new Dictionary<string, string>(); | ||
750 | param["?regionID"] = regionID.ToString(); | ||
751 | |||
752 | try | ||
753 | { | ||
754 | m_database.ExecuteParameterizedSql( | ||
755 | "update " + m_agentsTableName + " SET agentOnline = 0 " + | ||
756 | "where currentRegion = ?regionID", | ||
757 | param); | ||
758 | } | ||
759 | catch (Exception e) | ||
760 | { | ||
761 | m_log.Error(e.Message, e); | ||
762 | return; | ||
763 | } | ||
764 | } | ||
765 | } | ||
766 | } | ||
diff --git a/OpenSim/Data/MySQL/Tests/MySQLAssetTest.cs b/OpenSim/Data/MySQL/Tests/MySQLAssetTest.cs index e1d3f81..a46fdf8 100644 --- a/OpenSim/Data/MySQL/Tests/MySQLAssetTest.cs +++ b/OpenSim/Data/MySQL/Tests/MySQLAssetTest.cs | |||
@@ -31,6 +31,7 @@ using OpenSim.Data.Tests; | |||
31 | using log4net; | 31 | using log4net; |
32 | using System.Reflection; | 32 | using System.Reflection; |
33 | using OpenSim.Tests.Common; | 33 | using OpenSim.Tests.Common; |
34 | using MySql.Data.MySqlClient; | ||
34 | 35 | ||
35 | namespace OpenSim.Data.MySQL.Tests | 36 | namespace OpenSim.Data.MySQL.Tests |
36 | { | 37 | { |
@@ -39,7 +40,7 @@ namespace OpenSim.Data.MySQL.Tests | |||
39 | { | 40 | { |
40 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 41 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
41 | public string file; | 42 | public string file; |
42 | public MySQLManager database; | 43 | private string m_connectionString; |
43 | public string connect = "Server=localhost;Port=3306;Database=opensim-nunit;User ID=opensim-nunit;Password=opensim-nunit;Pooling=false;"; | 44 | public string connect = "Server=localhost;Port=3306;Database=opensim-nunit;User ID=opensim-nunit;Password=opensim-nunit;Pooling=false;"; |
44 | 45 | ||
45 | [TestFixtureSetUp] | 46 | [TestFixtureSetUp] |
@@ -52,7 +53,6 @@ namespace OpenSim.Data.MySQL.Tests | |||
52 | // tests. | 53 | // tests. |
53 | try | 54 | try |
54 | { | 55 | { |
55 | database = new MySQLManager(connect); | ||
56 | db = new MySQLAssetData(); | 56 | db = new MySQLAssetData(); |
57 | db.Initialise(connect); | 57 | db.Initialise(connect); |
58 | } | 58 | } |
@@ -70,10 +70,22 @@ namespace OpenSim.Data.MySQL.Tests | |||
70 | { | 70 | { |
71 | db.Dispose(); | 71 | db.Dispose(); |
72 | } | 72 | } |
73 | if (database != null) | 73 | ExecuteSql("drop table migrations"); |
74 | ExecuteSql("drop table assets"); | ||
75 | } | ||
76 | |||
77 | /// <summary> | ||
78 | /// Execute a MySqlCommand | ||
79 | /// </summary> | ||
80 | /// <param name="sql">sql string to execute</param> | ||
81 | private void ExecuteSql(string sql) | ||
82 | { | ||
83 | using (MySqlConnection dbcon = new MySqlConnection(connect)) | ||
74 | { | 84 | { |
75 | database.ExecuteSql("drop table migrations"); | 85 | dbcon.Open(); |
76 | database.ExecuteSql("drop table assets"); | 86 | |
87 | MySqlCommand cmd = new MySqlCommand(sql, dbcon); | ||
88 | cmd.ExecuteNonQuery(); | ||
77 | } | 89 | } |
78 | } | 90 | } |
79 | } | 91 | } |
diff --git a/OpenSim/Data/MySQL/Tests/MySQLEstateTest.cs b/OpenSim/Data/MySQL/Tests/MySQLEstateTest.cs index 48486b1..01afcae 100644 --- a/OpenSim/Data/MySQL/Tests/MySQLEstateTest.cs +++ b/OpenSim/Data/MySQL/Tests/MySQLEstateTest.cs | |||
@@ -31,6 +31,8 @@ using OpenSim.Data.Tests; | |||
31 | using log4net; | 31 | using log4net; |
32 | using System.Reflection; | 32 | using System.Reflection; |
33 | using OpenSim.Tests.Common; | 33 | using OpenSim.Tests.Common; |
34 | using MySql.Data.MySqlClient; | ||
35 | |||
34 | 36 | ||
35 | namespace OpenSim.Data.MySQL.Tests | 37 | namespace OpenSim.Data.MySQL.Tests |
36 | { | 38 | { |
@@ -39,7 +41,6 @@ namespace OpenSim.Data.MySQL.Tests | |||
39 | { | 41 | { |
40 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 42 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
41 | public string file; | 43 | public string file; |
42 | public MySQLManager database; | ||
43 | public string connect = "Server=localhost;Port=3306;Database=opensim-nunit;User ID=opensim-nunit;Password=opensim-nunit;Pooling=false;"; | 44 | public string connect = "Server=localhost;Port=3306;Database=opensim-nunit;User ID=opensim-nunit;Password=opensim-nunit;Pooling=false;"; |
44 | 45 | ||
45 | [TestFixtureSetUp] | 46 | [TestFixtureSetUp] |
@@ -52,9 +53,8 @@ namespace OpenSim.Data.MySQL.Tests | |||
52 | // tests. | 53 | // tests. |
53 | try | 54 | try |
54 | { | 55 | { |
55 | database = new MySQLManager(connect); | ||
56 | // clear db incase to ensure we are in a clean state | 56 | // clear db incase to ensure we are in a clean state |
57 | ClearDB(database); | 57 | ClearDB(); |
58 | 58 | ||
59 | regionDb = new MySQLDataStore(); | 59 | regionDb = new MySQLDataStore(); |
60 | regionDb.Initialise(connect); | 60 | regionDb.Initialise(connect); |
@@ -75,29 +75,41 @@ namespace OpenSim.Data.MySQL.Tests | |||
75 | { | 75 | { |
76 | regionDb.Dispose(); | 76 | regionDb.Dispose(); |
77 | } | 77 | } |
78 | ClearDB(database); | 78 | ClearDB(); |
79 | } | 79 | } |
80 | 80 | ||
81 | private void ClearDB(MySQLManager manager) | 81 | private void ClearDB() |
82 | { | 82 | { |
83 | // if a new table is added, it has to be dropped here | 83 | // if a new table is added, it has to be dropped here |
84 | if (manager != null) | 84 | ExecuteSql("drop table if exists migrations"); |
85 | ExecuteSql("drop table if exists prims"); | ||
86 | ExecuteSql("drop table if exists primshapes"); | ||
87 | ExecuteSql("drop table if exists primitems"); | ||
88 | ExecuteSql("drop table if exists terrain"); | ||
89 | ExecuteSql("drop table if exists land"); | ||
90 | ExecuteSql("drop table if exists landaccesslist"); | ||
91 | ExecuteSql("drop table if exists regionban"); | ||
92 | ExecuteSql("drop table if exists regionsettings"); | ||
93 | ExecuteSql("drop table if exists estate_managers"); | ||
94 | ExecuteSql("drop table if exists estate_groups"); | ||
95 | ExecuteSql("drop table if exists estate_users"); | ||
96 | ExecuteSql("drop table if exists estateban"); | ||
97 | ExecuteSql("drop table if exists estate_settings"); | ||
98 | ExecuteSql("drop table if exists estate_map"); | ||
99 | } | ||
100 | |||
101 | /// <summary> | ||
102 | /// Execute a MySqlCommand | ||
103 | /// </summary> | ||
104 | /// <param name="sql">sql string to execute</param> | ||
105 | private void ExecuteSql(string sql) | ||
106 | { | ||
107 | using (MySqlConnection dbcon = new MySqlConnection(connect)) | ||
85 | { | 108 | { |
86 | manager.ExecuteSql("drop table if exists migrations"); | 109 | dbcon.Open(); |
87 | manager.ExecuteSql("drop table if exists prims"); | 110 | |
88 | manager.ExecuteSql("drop table if exists primshapes"); | 111 | MySqlCommand cmd = new MySqlCommand(sql, dbcon); |
89 | manager.ExecuteSql("drop table if exists primitems"); | 112 | cmd.ExecuteNonQuery(); |
90 | manager.ExecuteSql("drop table if exists terrain"); | ||
91 | manager.ExecuteSql("drop table if exists land"); | ||
92 | manager.ExecuteSql("drop table if exists landaccesslist"); | ||
93 | manager.ExecuteSql("drop table if exists regionban"); | ||
94 | manager.ExecuteSql("drop table if exists regionsettings"); | ||
95 | manager.ExecuteSql("drop table if exists estate_managers"); | ||
96 | manager.ExecuteSql("drop table if exists estate_groups"); | ||
97 | manager.ExecuteSql("drop table if exists estate_users"); | ||
98 | manager.ExecuteSql("drop table if exists estateban"); | ||
99 | manager.ExecuteSql("drop table if exists estate_settings"); | ||
100 | manager.ExecuteSql("drop table if exists estate_map"); | ||
101 | } | 113 | } |
102 | } | 114 | } |
103 | } | 115 | } |
diff --git a/OpenSim/Data/MySQL/Tests/MySQLGridTest.cs b/OpenSim/Data/MySQL/Tests/MySQLGridTest.cs deleted file mode 100644 index 8272316..0000000 --- a/OpenSim/Data/MySQL/Tests/MySQLGridTest.cs +++ /dev/null | |||
@@ -1,94 +0,0 @@ | |||
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 NUnit.Framework; | ||
30 | using OpenSim.Data.Tests; | ||
31 | using log4net; | ||
32 | using System.Reflection; | ||
33 | using OpenSim.Tests.Common; | ||
34 | using MySql.Data.MySqlClient; | ||
35 | |||
36 | namespace OpenSim.Data.MySQL.Tests | ||
37 | { | ||
38 | [TestFixture, DatabaseTest] | ||
39 | public class MySQLGridTest : BasicGridTest | ||
40 | { | ||
41 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
42 | |||
43 | public string file; | ||
44 | public MySQLManager database; | ||
45 | public string connect = "Server=localhost;Port=3306;Database=opensim-nunit;User ID=opensim-nunit;Password=opensim-nunit;Pooling=false;"; | ||
46 | |||
47 | [TestFixtureSetUp] | ||
48 | public void Init() | ||
49 | { | ||
50 | SuperInit(); | ||
51 | // If we manage to connect to the database with the user | ||
52 | // and password above it is our test database, and run | ||
53 | // these tests. If anything goes wrong, ignore these | ||
54 | // tests. | ||
55 | try | ||
56 | { | ||
57 | database = new MySQLManager(connect); | ||
58 | db = new MySQLGridData(); | ||
59 | db.Initialise(connect); | ||
60 | } | ||
61 | catch (Exception e) | ||
62 | { | ||
63 | m_log.Error("Exception {0}", e); | ||
64 | Assert.Ignore(); | ||
65 | } | ||
66 | |||
67 | // This actually does the roll forward assembly stuff | ||
68 | Assembly assem = GetType().Assembly; | ||
69 | |||
70 | using (MySqlConnection dbcon = new MySqlConnection(connect)) | ||
71 | { | ||
72 | dbcon.Open(); | ||
73 | Migration m = new Migration(dbcon, assem, "AssetStore"); | ||
74 | m.Update(); | ||
75 | } | ||
76 | } | ||
77 | |||
78 | [TestFixtureTearDown] | ||
79 | public void Cleanup() | ||
80 | { | ||
81 | m_log.Warn("Cleaning up."); | ||
82 | if (db != null) | ||
83 | { | ||
84 | db.Dispose(); | ||
85 | } | ||
86 | // if a new table is added, it has to be dropped here | ||
87 | if (database != null) | ||
88 | { | ||
89 | database.ExecuteSql("drop table migrations"); | ||
90 | database.ExecuteSql("drop table regions"); | ||
91 | } | ||
92 | } | ||
93 | } | ||
94 | } | ||
diff --git a/OpenSim/Data/MySQL/Tests/MySQLInventoryTest.cs b/OpenSim/Data/MySQL/Tests/MySQLInventoryTest.cs index a3a32dc..4575493 100644 --- a/OpenSim/Data/MySQL/Tests/MySQLInventoryTest.cs +++ b/OpenSim/Data/MySQL/Tests/MySQLInventoryTest.cs | |||
@@ -31,6 +31,8 @@ using OpenSim.Data.Tests; | |||
31 | using log4net; | 31 | using log4net; |
32 | using System.Reflection; | 32 | using System.Reflection; |
33 | using OpenSim.Tests.Common; | 33 | using OpenSim.Tests.Common; |
34 | using MySql.Data.MySqlClient; | ||
35 | |||
34 | 36 | ||
35 | namespace OpenSim.Data.MySQL.Tests | 37 | namespace OpenSim.Data.MySQL.Tests |
36 | { | 38 | { |
@@ -39,7 +41,6 @@ namespace OpenSim.Data.MySQL.Tests | |||
39 | { | 41 | { |
40 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 42 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
41 | public string file; | 43 | public string file; |
42 | public MySQLManager database; | ||
43 | public string connect = "Server=localhost;Port=3306;Database=opensim-nunit;User ID=opensim-nunit;Password=opensim-nunit;Pooling=false;"; | 44 | public string connect = "Server=localhost;Port=3306;Database=opensim-nunit;User ID=opensim-nunit;Password=opensim-nunit;Pooling=false;"; |
44 | 45 | ||
45 | [TestFixtureSetUp] | 46 | [TestFixtureSetUp] |
@@ -52,7 +53,6 @@ namespace OpenSim.Data.MySQL.Tests | |||
52 | // tests. | 53 | // tests. |
53 | try | 54 | try |
54 | { | 55 | { |
55 | database = new MySQLManager(connect); | ||
56 | DropTables(); | 56 | DropTables(); |
57 | db = new MySQLInventoryData(); | 57 | db = new MySQLInventoryData(); |
58 | db.Initialise(connect); | 58 | db.Initialise(connect); |
@@ -71,17 +71,29 @@ namespace OpenSim.Data.MySQL.Tests | |||
71 | { | 71 | { |
72 | db.Dispose(); | 72 | db.Dispose(); |
73 | } | 73 | } |
74 | if (database != null) | 74 | DropTables(); |
75 | { | ||
76 | DropTables(); | ||
77 | } | ||
78 | } | 75 | } |
79 | 76 | ||
80 | private void DropTables() | 77 | private void DropTables() |
81 | { | 78 | { |
82 | database.ExecuteSql("drop table IF EXISTS inventoryitems"); | 79 | ExecuteSql("drop table IF EXISTS inventoryitems"); |
83 | database.ExecuteSql("drop table IF EXISTS inventoryfolders"); | 80 | ExecuteSql("drop table IF EXISTS inventoryfolders"); |
84 | database.ExecuteSql("drop table IF EXISTS migrations"); | 81 | ExecuteSql("drop table IF EXISTS migrations"); |
82 | } | ||
83 | |||
84 | /// <summary> | ||
85 | /// Execute a MySqlCommand | ||
86 | /// </summary> | ||
87 | /// <param name="sql">sql string to execute</param> | ||
88 | private void ExecuteSql(string sql) | ||
89 | { | ||
90 | using (MySqlConnection dbcon = new MySqlConnection(connect)) | ||
91 | { | ||
92 | dbcon.Open(); | ||
93 | |||
94 | MySqlCommand cmd = new MySqlCommand(sql, dbcon); | ||
95 | cmd.ExecuteNonQuery(); | ||
96 | } | ||
85 | } | 97 | } |
86 | } | 98 | } |
87 | } | 99 | } |
diff --git a/OpenSim/Data/MySQL/Tests/MySQLRegionTest.cs b/OpenSim/Data/MySQL/Tests/MySQLRegionTest.cs index 0dc8b7d..e7e57e4 100644 --- a/OpenSim/Data/MySQL/Tests/MySQLRegionTest.cs +++ b/OpenSim/Data/MySQL/Tests/MySQLRegionTest.cs | |||
@@ -31,6 +31,7 @@ using OpenSim.Data.Tests; | |||
31 | using log4net; | 31 | using log4net; |
32 | using System.Reflection; | 32 | using System.Reflection; |
33 | using OpenSim.Tests.Common; | 33 | using OpenSim.Tests.Common; |
34 | using MySql.Data.MySqlClient; | ||
34 | 35 | ||
35 | namespace OpenSim.Data.MySQL.Tests | 36 | namespace OpenSim.Data.MySQL.Tests |
36 | { | 37 | { |
@@ -39,7 +40,6 @@ namespace OpenSim.Data.MySQL.Tests | |||
39 | { | 40 | { |
40 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 41 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
41 | public string file; | 42 | public string file; |
42 | public MySQLManager database; | ||
43 | public string connect = "Server=localhost;Port=3306;Database=opensim-nunit;User ID=opensim-nunit;Password=opensim-nunit;Pooling=false;"; | 43 | public string connect = "Server=localhost;Port=3306;Database=opensim-nunit;User ID=opensim-nunit;Password=opensim-nunit;Pooling=false;"; |
44 | 44 | ||
45 | [TestFixtureSetUp] | 45 | [TestFixtureSetUp] |
@@ -52,9 +52,8 @@ namespace OpenSim.Data.MySQL.Tests | |||
52 | // tests. | 52 | // tests. |
53 | try | 53 | try |
54 | { | 54 | { |
55 | database = new MySQLManager(connect); | ||
56 | // this is important in case a previous run ended badly | 55 | // this is important in case a previous run ended badly |
57 | ClearDB(database); | 56 | ClearDB(); |
58 | 57 | ||
59 | db = new MySQLDataStore(); | 58 | db = new MySQLDataStore(); |
60 | db.Initialise(connect); | 59 | db.Initialise(connect); |
@@ -73,28 +72,40 @@ namespace OpenSim.Data.MySQL.Tests | |||
73 | { | 72 | { |
74 | db.Dispose(); | 73 | db.Dispose(); |
75 | } | 74 | } |
76 | ClearDB(database); | 75 | ClearDB(); |
77 | } | 76 | } |
78 | 77 | ||
79 | private void ClearDB(MySQLManager manager) | 78 | private void ClearDB() |
80 | { | 79 | { |
81 | if (manager != null) | 80 | ExecuteSql("drop table if exists migrations"); |
81 | ExecuteSql("drop table if exists prims"); | ||
82 | ExecuteSql("drop table if exists primshapes"); | ||
83 | ExecuteSql("drop table if exists primitems"); | ||
84 | ExecuteSql("drop table if exists terrain"); | ||
85 | ExecuteSql("drop table if exists land"); | ||
86 | ExecuteSql("drop table if exists landaccesslist"); | ||
87 | ExecuteSql("drop table if exists regionban"); | ||
88 | ExecuteSql("drop table if exists regionsettings"); | ||
89 | ExecuteSql("drop table if exists estate_managers"); | ||
90 | ExecuteSql("drop table if exists estate_groups"); | ||
91 | ExecuteSql("drop table if exists estate_users"); | ||
92 | ExecuteSql("drop table if exists estateban"); | ||
93 | ExecuteSql("drop table if exists estate_settings"); | ||
94 | ExecuteSql("drop table if exists estate_map"); | ||
95 | } | ||
96 | |||
97 | /// <summary> | ||
98 | /// Execute a MySqlCommand | ||
99 | /// </summary> | ||
100 | /// <param name="sql">sql string to execute</param> | ||
101 | private void ExecuteSql(string sql) | ||
102 | { | ||
103 | using (MySqlConnection dbcon = new MySqlConnection(connect)) | ||
82 | { | 104 | { |
83 | manager.ExecuteSql("drop table if exists migrations"); | 105 | dbcon.Open(); |
84 | manager.ExecuteSql("drop table if exists prims"); | 106 | |
85 | manager.ExecuteSql("drop table if exists primshapes"); | 107 | MySqlCommand cmd = new MySqlCommand(sql, dbcon); |
86 | manager.ExecuteSql("drop table if exists primitems"); | 108 | cmd.ExecuteNonQuery(); |
87 | manager.ExecuteSql("drop table if exists terrain"); | ||
88 | manager.ExecuteSql("drop table if exists land"); | ||
89 | manager.ExecuteSql("drop table if exists landaccesslist"); | ||
90 | manager.ExecuteSql("drop table if exists regionban"); | ||
91 | manager.ExecuteSql("drop table if exists regionsettings"); | ||
92 | manager.ExecuteSql("drop table if exists estate_managers"); | ||
93 | manager.ExecuteSql("drop table if exists estate_groups"); | ||
94 | manager.ExecuteSql("drop table if exists estate_users"); | ||
95 | manager.ExecuteSql("drop table if exists estateban"); | ||
96 | manager.ExecuteSql("drop table if exists estate_settings"); | ||
97 | manager.ExecuteSql("drop table if exists estate_map"); | ||
98 | } | 109 | } |
99 | } | 110 | } |
100 | } | 111 | } |
diff --git a/OpenSim/Data/Null/NullPresenceData.cs b/OpenSim/Data/Null/NullPresenceData.cs index 40700cf..5f78691 100644 --- a/OpenSim/Data/Null/NullPresenceData.cs +++ b/OpenSim/Data/Null/NullPresenceData.cs | |||
@@ -43,16 +43,18 @@ namespace OpenSim.Data.Null | |||
43 | public NullPresenceData(string connectionString, string realm) | 43 | public NullPresenceData(string connectionString, string realm) |
44 | { | 44 | { |
45 | if (Instance == null) | 45 | if (Instance == null) |
46 | { | ||
46 | Instance = this; | 47 | Instance = this; |
47 | 48 | ||
48 | //Console.WriteLine("[XXX] NullRegionData constructor"); | 49 | //Console.WriteLine("[XXX] NullRegionData constructor"); |
49 | // Let's stick in a test presence | 50 | // Let's stick in a test presence |
50 | PresenceData p = new PresenceData(); | 51 | PresenceData p = new PresenceData(); |
51 | p.SessionID = UUID.Zero; | 52 | p.SessionID = UUID.Zero; |
52 | p.UserID = UUID.Zero.ToString(); | 53 | p.UserID = UUID.Zero.ToString(); |
53 | p.Data = new Dictionary<string, string>(); | 54 | p.Data = new Dictionary<string, string>(); |
54 | p.Data["Online"] = "true"; | 55 | p.Data["Online"] = true.ToString(); |
55 | m_presenceData.Add(UUID.Zero, p); | 56 | m_presenceData.Add(UUID.Zero, p); |
57 | } | ||
56 | } | 58 | } |
57 | 59 | ||
58 | public bool Store(PresenceData data) | 60 | public bool Store(PresenceData data) |
@@ -70,7 +72,9 @@ namespace OpenSim.Data.Null | |||
70 | return Instance.Get(sessionID); | 72 | return Instance.Get(sessionID); |
71 | 73 | ||
72 | if (m_presenceData.ContainsKey(sessionID)) | 74 | if (m_presenceData.ContainsKey(sessionID)) |
75 | { | ||
73 | return m_presenceData[sessionID]; | 76 | return m_presenceData[sessionID]; |
77 | } | ||
74 | 78 | ||
75 | return null; | 79 | return null; |
76 | } | 80 | } |
diff --git a/OpenSim/Data/RegionProfileData.cs b/OpenSim/Data/RegionProfileData.cs deleted file mode 100644 index 90713d2..0000000 --- a/OpenSim/Data/RegionProfileData.cs +++ /dev/null | |||
@@ -1,337 +0,0 @@ | |||
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 Nwc.XmlRpc; | ||
31 | using OpenMetaverse; | ||
32 | using OpenSim.Framework; | ||
33 | |||
34 | namespace OpenSim.Data | ||
35 | { | ||
36 | /// <summary> | ||
37 | /// A class which contains information known to the grid server about a region | ||
38 | /// </summary> | ||
39 | [Serializable] | ||
40 | public class RegionProfileData | ||
41 | { | ||
42 | /// <summary> | ||
43 | /// The name of the region | ||
44 | /// </summary> | ||
45 | public string regionName = String.Empty; | ||
46 | |||
47 | /// <summary> | ||
48 | /// A 64-bit number combining map position into a (mostly) unique ID | ||
49 | /// </summary> | ||
50 | public ulong regionHandle; | ||
51 | |||
52 | /// <summary> | ||
53 | /// OGS/OpenSim Specific ID for a region | ||
54 | /// </summary> | ||
55 | public UUID UUID; | ||
56 | |||
57 | /// <summary> | ||
58 | /// Coordinates of the region | ||
59 | /// </summary> | ||
60 | public uint regionLocX; | ||
61 | public uint regionLocY; | ||
62 | public uint regionLocZ; // Reserved (round-robin, layers, etc) | ||
63 | |||
64 | /// <summary> | ||
65 | /// Authentication secrets | ||
66 | /// </summary> | ||
67 | /// <remarks>Not very secure, needs improvement.</remarks> | ||
68 | public string regionSendKey = String.Empty; | ||
69 | public string regionRecvKey = String.Empty; | ||
70 | public string regionSecret = String.Empty; | ||
71 | |||
72 | /// <summary> | ||
73 | /// Whether the region is online | ||
74 | /// </summary> | ||
75 | public bool regionOnline; | ||
76 | |||
77 | /// <summary> | ||
78 | /// Information about the server that the region is currently hosted on | ||
79 | /// </summary> | ||
80 | public string serverIP = String.Empty; | ||
81 | public uint serverPort; | ||
82 | public string serverURI = String.Empty; | ||
83 | |||
84 | public uint httpPort; | ||
85 | public uint remotingPort; | ||
86 | public string httpServerURI = String.Empty; | ||
87 | |||
88 | /// <summary> | ||
89 | /// Set of optional overrides. Can be used to create non-eulicidean spaces. | ||
90 | /// </summary> | ||
91 | public ulong regionNorthOverrideHandle; | ||
92 | public ulong regionSouthOverrideHandle; | ||
93 | public ulong regionEastOverrideHandle; | ||
94 | public ulong regionWestOverrideHandle; | ||
95 | |||
96 | /// <summary> | ||
97 | /// Optional: URI Location of the region database | ||
98 | /// </summary> | ||
99 | /// <remarks>Used for floating sim pools where the region data is not nessecarily coupled to a specific server</remarks> | ||
100 | public string regionDataURI = String.Empty; | ||
101 | |||
102 | /// <summary> | ||
103 | /// Region Asset Details | ||
104 | /// </summary> | ||
105 | public string regionAssetURI = String.Empty; | ||
106 | |||
107 | public string regionAssetSendKey = String.Empty; | ||
108 | public string regionAssetRecvKey = String.Empty; | ||
109 | |||
110 | /// <summary> | ||
111 | /// Region Userserver Details | ||
112 | /// </summary> | ||
113 | public string regionUserURI = String.Empty; | ||
114 | |||
115 | public string regionUserSendKey = String.Empty; | ||
116 | public string regionUserRecvKey = String.Empty; | ||
117 | |||
118 | /// <summary> | ||
119 | /// Region Map Texture Asset | ||
120 | /// </summary> | ||
121 | public UUID regionMapTextureID = new UUID("00000000-0000-1111-9999-000000000006"); | ||
122 | |||
123 | /// <summary> | ||
124 | /// this particular mod to the file provides support within the spec for RegionProfileData for the | ||
125 | /// owner_uuid for the region | ||
126 | /// </summary> | ||
127 | public UUID owner_uuid = UUID.Zero; | ||
128 | |||
129 | /// <summary> | ||
130 | /// OGS/OpenSim Specific original ID for a region after move/split | ||
131 | /// </summary> | ||
132 | public UUID originUUID; | ||
133 | |||
134 | /// <summary> | ||
135 | /// The Maturity rating of the region | ||
136 | /// </summary> | ||
137 | public uint maturity; | ||
138 | |||
139 | //Data Wrappers | ||
140 | public string RegionName | ||
141 | { | ||
142 | get { return regionName; } | ||
143 | set { regionName = value; } | ||
144 | } | ||
145 | public ulong RegionHandle | ||
146 | { | ||
147 | get { return regionHandle; } | ||
148 | set { regionHandle = value; } | ||
149 | } | ||
150 | public UUID Uuid | ||
151 | { | ||
152 | get { return UUID; } | ||
153 | set { UUID = value; } | ||
154 | } | ||
155 | public uint RegionLocX | ||
156 | { | ||
157 | get { return regionLocX; } | ||
158 | set { regionLocX = value; } | ||
159 | } | ||
160 | public uint RegionLocY | ||
161 | { | ||
162 | get { return regionLocY; } | ||
163 | set { regionLocY = value; } | ||
164 | } | ||
165 | public uint RegionLocZ | ||
166 | { | ||
167 | get { return regionLocZ; } | ||
168 | set { regionLocZ = value; } | ||
169 | } | ||
170 | public string RegionSendKey | ||
171 | { | ||
172 | get { return regionSendKey; } | ||
173 | set { regionSendKey = value; } | ||
174 | } | ||
175 | public string RegionRecvKey | ||
176 | { | ||
177 | get { return regionRecvKey; } | ||
178 | set { regionRecvKey = value; } | ||
179 | } | ||
180 | public string RegionSecret | ||
181 | { | ||
182 | get { return regionSecret; } | ||
183 | set { regionSecret = value; } | ||
184 | } | ||
185 | public bool RegionOnline | ||
186 | { | ||
187 | get { return regionOnline; } | ||
188 | set { regionOnline = value; } | ||
189 | } | ||
190 | public string ServerIP | ||
191 | { | ||
192 | get { return serverIP; } | ||
193 | set { serverIP = value; } | ||
194 | } | ||
195 | public uint ServerPort | ||
196 | { | ||
197 | get { return serverPort; } | ||
198 | set { serverPort = value; } | ||
199 | } | ||
200 | public string ServerURI | ||
201 | { | ||
202 | get { return serverURI; } | ||
203 | set { serverURI = value; } | ||
204 | } | ||
205 | public uint ServerHttpPort | ||
206 | { | ||
207 | get { return httpPort; } | ||
208 | set { httpPort = value; } | ||
209 | } | ||
210 | public uint ServerRemotingPort | ||
211 | { | ||
212 | get { return remotingPort; } | ||
213 | set { remotingPort = value; } | ||
214 | } | ||
215 | |||
216 | public ulong NorthOverrideHandle | ||
217 | { | ||
218 | get { return regionNorthOverrideHandle; } | ||
219 | set { regionNorthOverrideHandle = value; } | ||
220 | } | ||
221 | public ulong SouthOverrideHandle | ||
222 | { | ||
223 | get { return regionSouthOverrideHandle; } | ||
224 | set { regionSouthOverrideHandle = value; } | ||
225 | } | ||
226 | public ulong EastOverrideHandle | ||
227 | { | ||
228 | get { return regionEastOverrideHandle; } | ||
229 | set { regionEastOverrideHandle = value; } | ||
230 | } | ||
231 | public ulong WestOverrideHandle | ||
232 | { | ||
233 | get { return regionWestOverrideHandle; } | ||
234 | set { regionWestOverrideHandle = value; } | ||
235 | } | ||
236 | public string RegionDataURI | ||
237 | { | ||
238 | get { return regionDataURI; } | ||
239 | set { regionDataURI = value; } | ||
240 | } | ||
241 | public string RegionAssetURI | ||
242 | { | ||
243 | get { return regionAssetURI; } | ||
244 | set { regionAssetURI = value; } | ||
245 | } | ||
246 | public string RegionAssetSendKey | ||
247 | { | ||
248 | get { return regionAssetSendKey; } | ||
249 | set { regionAssetSendKey = value; } | ||
250 | } | ||
251 | public string RegionAssetRecvKey | ||
252 | { | ||
253 | get { return regionAssetRecvKey; } | ||
254 | set { regionAssetRecvKey = value; } | ||
255 | } | ||
256 | public string RegionUserURI | ||
257 | { | ||
258 | get { return regionUserURI; } | ||
259 | set { regionUserURI = value; } | ||
260 | } | ||
261 | public string RegionUserSendKey | ||
262 | { | ||
263 | get { return regionUserSendKey; } | ||
264 | set { regionUserSendKey = value; } | ||
265 | } | ||
266 | public string RegionUserRecvKey | ||
267 | { | ||
268 | get { return regionUserRecvKey; } | ||
269 | set { regionUserRecvKey = value; } | ||
270 | } | ||
271 | public UUID RegionMapTextureID | ||
272 | { | ||
273 | get { return regionMapTextureID; } | ||
274 | set { regionMapTextureID = value; } | ||
275 | } | ||
276 | public UUID Owner_uuid | ||
277 | { | ||
278 | get { return owner_uuid; } | ||
279 | set { owner_uuid = value; } | ||
280 | } | ||
281 | public UUID OriginUUID | ||
282 | { | ||
283 | get { return originUUID; } | ||
284 | set { originUUID = value; } | ||
285 | } | ||
286 | public uint Maturity | ||
287 | { | ||
288 | get { return maturity; } | ||
289 | set { maturity = value; } | ||
290 | } | ||
291 | |||
292 | public byte AccessLevel | ||
293 | { | ||
294 | get { return Util.ConvertMaturityToAccessLevel(maturity); } | ||
295 | } | ||
296 | |||
297 | |||
298 | public RegionInfo ToRegionInfo() | ||
299 | { | ||
300 | return RegionInfo.Create(UUID, regionName, regionLocX, regionLocY, serverIP, httpPort, serverPort, remotingPort, serverURI); | ||
301 | } | ||
302 | |||
303 | public static RegionProfileData FromRegionInfo(RegionInfo regionInfo) | ||
304 | { | ||
305 | if (regionInfo == null) | ||
306 | { | ||
307 | return null; | ||
308 | } | ||
309 | |||
310 | return Create(regionInfo.RegionID, regionInfo.RegionName, regionInfo.RegionLocX, | ||
311 | regionInfo.RegionLocY, regionInfo.ExternalHostName, | ||
312 | (uint) regionInfo.ExternalEndPoint.Port, regionInfo.HttpPort, regionInfo.RemotingPort, | ||
313 | regionInfo.ServerURI, regionInfo.AccessLevel); | ||
314 | } | ||
315 | |||
316 | public static RegionProfileData Create(UUID regionID, string regionName, uint locX, uint locY, string externalHostName, uint regionPort, uint httpPort, uint remotingPort, string serverUri, byte access) | ||
317 | { | ||
318 | RegionProfileData regionProfile; | ||
319 | regionProfile = new RegionProfileData(); | ||
320 | regionProfile.regionLocX = locX; | ||
321 | regionProfile.regionLocY = locY; | ||
322 | regionProfile.regionHandle = | ||
323 | Utils.UIntsToLong((regionProfile.regionLocX * Constants.RegionSize), | ||
324 | (regionProfile.regionLocY*Constants.RegionSize)); | ||
325 | regionProfile.serverIP = externalHostName; | ||
326 | regionProfile.serverPort = regionPort; | ||
327 | regionProfile.httpPort = httpPort; | ||
328 | regionProfile.remotingPort = remotingPort; | ||
329 | regionProfile.serverURI = serverUri; | ||
330 | regionProfile.httpServerURI = "http://" + externalHostName + ":" + httpPort + "/"; | ||
331 | regionProfile.UUID = regionID; | ||
332 | regionProfile.regionName = regionName; | ||
333 | regionProfile.maturity = access; | ||
334 | return regionProfile; | ||
335 | } | ||
336 | } | ||
337 | } | ||
diff --git a/OpenSim/Data/RegionProfileServiceProxy.cs b/OpenSim/Data/RegionProfileServiceProxy.cs deleted file mode 100644 index 20d7df0..0000000 --- a/OpenSim/Data/RegionProfileServiceProxy.cs +++ /dev/null | |||
@@ -1,119 +0,0 @@ | |||
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.Text; | ||
32 | using Nwc.XmlRpc; | ||
33 | using OpenMetaverse; | ||
34 | using OpenSim.Framework; | ||
35 | |||
36 | namespace OpenSim.Data | ||
37 | { | ||
38 | public class RegionProfileServiceProxy : IRegionProfileRouter | ||
39 | { | ||
40 | /// <summary> | ||
41 | /// Request sim data based on arbitrary key/value | ||
42 | /// </summary> | ||
43 | private RegionProfileData RequestSimData(Uri gridserverUrl, string gridserverSendkey, string keyField, string keyValue) | ||
44 | { | ||
45 | Hashtable requestData = new Hashtable(); | ||
46 | requestData[keyField] = keyValue; | ||
47 | requestData["authkey"] = gridserverSendkey; | ||
48 | ArrayList SendParams = new ArrayList(); | ||
49 | SendParams.Add(requestData); | ||
50 | XmlRpcRequest GridReq = new XmlRpcRequest("simulator_data_request", SendParams); | ||
51 | XmlRpcResponse GridResp = GridReq.Send(gridserverUrl.ToString(), 3000); | ||
52 | |||
53 | Hashtable responseData = (Hashtable) GridResp.Value; | ||
54 | |||
55 | RegionProfileData simData = null; | ||
56 | |||
57 | if (!responseData.ContainsKey("error")) | ||
58 | { | ||
59 | uint locX = Convert.ToUInt32((string)responseData["region_locx"]); | ||
60 | uint locY = Convert.ToUInt32((string)responseData["region_locy"]); | ||
61 | string externalHostName = (string)responseData["sim_ip"]; | ||
62 | uint simPort = Convert.ToUInt32((string)responseData["sim_port"]); | ||
63 | uint httpPort = Convert.ToUInt32((string)responseData["http_port"]); | ||
64 | uint remotingPort = Convert.ToUInt32((string)responseData["remoting_port"]); | ||
65 | string serverUri = (string)responseData["server_uri"]; | ||
66 | UUID regionID = new UUID((string)responseData["region_UUID"]); | ||
67 | string regionName = (string)responseData["region_name"]; | ||
68 | byte access = Convert.ToByte((string)responseData["access"]); | ||
69 | |||
70 | simData = RegionProfileData.Create(regionID, regionName, locX, locY, externalHostName, simPort, httpPort, remotingPort, serverUri, access); | ||
71 | } | ||
72 | |||
73 | return simData; | ||
74 | } | ||
75 | |||
76 | /// <summary> | ||
77 | /// Request sim profile information from a grid server, by Region UUID | ||
78 | /// </summary> | ||
79 | /// <param name="regionId">The region UUID to look for</param> | ||
80 | /// <param name="gridserverUrl"></param> | ||
81 | /// <param name="gridserverSendkey"></param> | ||
82 | /// <param name="gridserverRecvkey"></param> | ||
83 | /// <returns>The sim profile. Null if there was a request failure</returns> | ||
84 | /// <remarks>This method should be statics</remarks> | ||
85 | public RegionProfileData RequestSimProfileData(UUID regionId, Uri gridserverUrl, | ||
86 | string gridserverSendkey, string gridserverRecvkey) | ||
87 | { | ||
88 | return RequestSimData(gridserverUrl, gridserverSendkey, "region_UUID", regionId.Guid.ToString()); | ||
89 | } | ||
90 | |||
91 | /// <summary> | ||
92 | /// Request sim profile information from a grid server, by Region Handle | ||
93 | /// </summary> | ||
94 | /// <param name="regionHandle">the region handle to look for</param> | ||
95 | /// <param name="gridserverUrl"></param> | ||
96 | /// <param name="gridserverSendkey"></param> | ||
97 | /// <param name="gridserverRecvkey"></param> | ||
98 | /// <returns>The sim profile. Null if there was a request failure</returns> | ||
99 | public RegionProfileData RequestSimProfileData(ulong regionHandle, Uri gridserverUrl, | ||
100 | string gridserverSendkey, string gridserverRecvkey) | ||
101 | { | ||
102 | return RequestSimData(gridserverUrl, gridserverSendkey, "region_handle", regionHandle.ToString()); | ||
103 | } | ||
104 | |||
105 | /// <summary> | ||
106 | /// Request sim profile information from a grid server, by Region Name | ||
107 | /// </summary> | ||
108 | /// <param name="regionName">the region name to look for</param> | ||
109 | /// <param name="gridserverUrl"></param> | ||
110 | /// <param name="gridserverSendkey"></param> | ||
111 | /// <param name="gridserverRecvkey"></param> | ||
112 | /// <returns>The sim profile. Null if there was a request failure</returns> | ||
113 | public RegionProfileData RequestSimProfileData(string regionName, Uri gridserverUrl, | ||
114 | string gridserverSendkey, string gridserverRecvkey) | ||
115 | { | ||
116 | return RequestSimData(gridserverUrl, gridserverSendkey, "region_name_search", regionName); | ||
117 | } | ||
118 | } | ||
119 | } | ||
diff --git a/OpenSim/Data/ReservationData.cs b/OpenSim/Data/ReservationData.cs deleted file mode 100644 index 3956fe6..0000000 --- a/OpenSim/Data/ReservationData.cs +++ /dev/null | |||
@@ -1,48 +0,0 @@ | |||
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 OpenMetaverse; | ||
30 | |||
31 | namespace OpenSim.Data | ||
32 | { | ||
33 | public class ReservationData | ||
34 | { | ||
35 | public UUID userUUID = UUID.Zero; | ||
36 | public int reservationMinX = 0; | ||
37 | public int reservationMinY = 0; | ||
38 | public int reservationMaxX = 65536; | ||
39 | public int reservationMaxY = 65536; | ||
40 | |||
41 | public string reservationName = String.Empty; | ||
42 | public string reservationCompany = String.Empty; | ||
43 | public bool status = true; | ||
44 | |||
45 | public string gridSendKey = String.Empty; | ||
46 | public string gridRecvKey = String.Empty; | ||
47 | } | ||
48 | } | ||
diff --git a/OpenSim/Data/SQLite/Resources/001_AuthStore.sql b/OpenSim/Data/SQLite/Resources/001_AuthStore.sql new file mode 100644 index 0000000..468567d --- /dev/null +++ b/OpenSim/Data/SQLite/Resources/001_AuthStore.sql | |||
@@ -0,0 +1,18 @@ | |||
1 | BEGIN TRANSACTION; | ||
2 | |||
3 | CREATE TABLE auth ( | ||
4 | UUID char(36) NOT NULL, | ||
5 | passwordHash char(32) NOT NULL default '', | ||
6 | passwordSalt char(32) NOT NULL default '', | ||
7 | webLoginKey varchar(255) NOT NULL default '', | ||
8 | accountType VARCHAR(32) NOT NULL DEFAULT 'UserAccount', | ||
9 | PRIMARY KEY (`UUID`) | ||
10 | ); | ||
11 | |||
12 | CREATE TABLE tokens ( | ||
13 | UUID char(36) NOT NULL, | ||
14 | token varchar(255) NOT NULL, | ||
15 | validity datetime NOT NULL | ||
16 | ); | ||
17 | |||
18 | COMMIT; | ||
diff --git a/OpenSim/Data/SQLite/Resources/001_Avatar.sql b/OpenSim/Data/SQLite/Resources/001_Avatar.sql new file mode 100644 index 0000000..7ec906b --- /dev/null +++ b/OpenSim/Data/SQLite/Resources/001_Avatar.sql | |||
@@ -0,0 +1,9 @@ | |||
1 | BEGIN TRANSACTION; | ||
2 | |||
3 | CREATE TABLE Avatars ( | ||
4 | PrincipalID CHAR(36) NOT NULL, | ||
5 | Name VARCHAR(32) NOT NULL, | ||
6 | Value VARCHAR(255) NOT NULL DEFAULT '', | ||
7 | PRIMARY KEY(PrincipalID, Name)); | ||
8 | |||
9 | COMMIT; | ||
diff --git a/OpenSim/Data/SQLite/Resources/001_UserAccount.sql b/OpenSim/Data/SQLite/Resources/001_UserAccount.sql new file mode 100644 index 0000000..f9bf24c --- /dev/null +++ b/OpenSim/Data/SQLite/Resources/001_UserAccount.sql | |||
@@ -0,0 +1,17 @@ | |||
1 | BEGIN TRANSACTION; | ||
2 | |||
3 | -- useraccounts table | ||
4 | CREATE TABLE UserAccounts ( | ||
5 | PrincipalID CHAR(36) NOT NULL, | ||
6 | ScopeID CHAR(36) NOT NULL, | ||
7 | FirstName VARCHAR(64) NOT NULL, | ||
8 | LastName VARCHAR(64) NOT NULL, | ||
9 | Email VARCHAR(64), | ||
10 | ServiceURLs TEXT, | ||
11 | Created INT(11), | ||
12 | UserLevel integer NOT NULL DEFAULT 0, | ||
13 | UserFlags integer NOT NULL DEFAULT 0, | ||
14 | UserTitle varchar(64) NOT NULL DEFAULT '' | ||
15 | ); | ||
16 | |||
17 | COMMIT; \ No newline at end of file | ||
diff --git a/OpenSim/Data/SQLite/Resources/002_AuthStore.sql b/OpenSim/Data/SQLite/Resources/002_AuthStore.sql new file mode 100644 index 0000000..3237b68 --- /dev/null +++ b/OpenSim/Data/SQLite/Resources/002_AuthStore.sql | |||
@@ -0,0 +1,5 @@ | |||
1 | BEGIN TRANSACTION; | ||
2 | |||
3 | INSERT INTO auth (UUID, passwordHash, passwordSalt, webLoginKey) SELECT `UUID` AS UUID, `passwordHash` AS passwordHash, `passwordSalt` AS passwordSalt, `webLoginKey` AS webLoginKey FROM users; | ||
4 | |||
5 | COMMIT; | ||
diff --git a/OpenSim/Data/SQLite/Resources/002_UserAccount.sql b/OpenSim/Data/SQLite/Resources/002_UserAccount.sql new file mode 100644 index 0000000..c7a6293 --- /dev/null +++ b/OpenSim/Data/SQLite/Resources/002_UserAccount.sql | |||
@@ -0,0 +1,5 @@ | |||
1 | BEGIN TRANSACTION; | ||
2 | |||
3 | INSERT INTO UserAccounts (PrincipalID, ScopeID, FirstName, LastName, Email, ServiceURLs, Created) SELECT `UUID` AS PrincipalID, '00000000-0000-0000-0000-000000000000' AS ScopeID, username AS FirstName, surname AS LastName, '' as Email, '' AS ServiceURLs, created as Created FROM users; | ||
4 | |||
5 | COMMIT; | ||
diff --git a/OpenSim/Data/SQLite/SQLiteAuthenticationData.cs b/OpenSim/Data/SQLite/SQLiteAuthenticationData.cs new file mode 100644 index 0000000..84ce775 --- /dev/null +++ b/OpenSim/Data/SQLite/SQLiteAuthenticationData.cs | |||
@@ -0,0 +1,262 @@ | |||
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.Data; | ||
32 | using OpenMetaverse; | ||
33 | using OpenSim.Framework; | ||
34 | using Mono.Data.SqliteClient; | ||
35 | |||
36 | namespace OpenSim.Data.SQLite | ||
37 | { | ||
38 | public class SQLiteAuthenticationData : SQLiteFramework, IAuthenticationData | ||
39 | { | ||
40 | private string m_Realm; | ||
41 | private List<string> m_ColumnNames; | ||
42 | private int m_LastExpire; | ||
43 | private string m_connectionString; | ||
44 | |||
45 | protected static SqliteConnection m_Connection; | ||
46 | private static bool m_initialized = false; | ||
47 | |||
48 | public SQLiteAuthenticationData(string connectionString, string realm) | ||
49 | : base(connectionString) | ||
50 | { | ||
51 | m_Realm = realm; | ||
52 | m_connectionString = connectionString; | ||
53 | |||
54 | if (!m_initialized) | ||
55 | { | ||
56 | m_Connection = new SqliteConnection(connectionString); | ||
57 | m_Connection.Open(); | ||
58 | |||
59 | using (SqliteConnection dbcon = (SqliteConnection)((ICloneable)m_Connection).Clone()) | ||
60 | { | ||
61 | dbcon.Open(); | ||
62 | Migration m = new Migration(dbcon, GetType().Assembly, "AuthStore"); | ||
63 | m.Update(); | ||
64 | dbcon.Close(); | ||
65 | } | ||
66 | |||
67 | m_initialized = true; | ||
68 | } | ||
69 | } | ||
70 | |||
71 | public AuthenticationData Get(UUID principalID) | ||
72 | { | ||
73 | AuthenticationData ret = new AuthenticationData(); | ||
74 | ret.Data = new Dictionary<string, object>(); | ||
75 | |||
76 | SqliteCommand cmd = new SqliteCommand("select * from `" + m_Realm + "` where UUID = :PrincipalID"); | ||
77 | cmd.Parameters.Add(new SqliteParameter(":PrincipalID", principalID.ToString())); | ||
78 | |||
79 | IDataReader result = ExecuteReader(cmd, m_Connection); | ||
80 | |||
81 | try | ||
82 | { | ||
83 | if (result.Read()) | ||
84 | { | ||
85 | ret.PrincipalID = principalID; | ||
86 | |||
87 | if (m_ColumnNames == null) | ||
88 | { | ||
89 | m_ColumnNames = new List<string>(); | ||
90 | |||
91 | DataTable schemaTable = result.GetSchemaTable(); | ||
92 | foreach (DataRow row in schemaTable.Rows) | ||
93 | m_ColumnNames.Add(row["ColumnName"].ToString()); | ||
94 | } | ||
95 | |||
96 | foreach (string s in m_ColumnNames) | ||
97 | { | ||
98 | if (s == "UUID") | ||
99 | continue; | ||
100 | |||
101 | ret.Data[s] = result[s].ToString(); | ||
102 | } | ||
103 | |||
104 | return ret; | ||
105 | } | ||
106 | else | ||
107 | { | ||
108 | return null; | ||
109 | } | ||
110 | } | ||
111 | catch | ||
112 | { | ||
113 | } | ||
114 | finally | ||
115 | { | ||
116 | CloseCommand(cmd); | ||
117 | } | ||
118 | |||
119 | return null; | ||
120 | } | ||
121 | |||
122 | public bool Store(AuthenticationData data) | ||
123 | { | ||
124 | if (data.Data.ContainsKey("UUID")) | ||
125 | data.Data.Remove("UUID"); | ||
126 | |||
127 | string[] fields = new List<string>(data.Data.Keys).ToArray(); | ||
128 | string[] values = new string[data.Data.Count]; | ||
129 | int i = 0; | ||
130 | foreach (object o in data.Data.Values) | ||
131 | values[i++] = o.ToString(); | ||
132 | |||
133 | SqliteCommand cmd = new SqliteCommand(); | ||
134 | |||
135 | if (Get(data.PrincipalID) != null) | ||
136 | { | ||
137 | |||
138 | |||
139 | string update = "update `" + m_Realm + "` set "; | ||
140 | bool first = true; | ||
141 | foreach (string field in fields) | ||
142 | { | ||
143 | if (!first) | ||
144 | update += ", "; | ||
145 | update += "`" + field + "` = :" + field; | ||
146 | cmd.Parameters.Add(new SqliteParameter(":" + field, data.Data[field])); | ||
147 | |||
148 | first = false; | ||
149 | } | ||
150 | |||
151 | update += " where UUID = :UUID"; | ||
152 | cmd.Parameters.Add(new SqliteParameter(":UUID", data.PrincipalID.ToString())); | ||
153 | |||
154 | cmd.CommandText = update; | ||
155 | try | ||
156 | { | ||
157 | if (ExecuteNonQuery(cmd, m_Connection) < 1) | ||
158 | { | ||
159 | CloseCommand(cmd); | ||
160 | return false; | ||
161 | } | ||
162 | } | ||
163 | catch (Exception e) | ||
164 | { | ||
165 | Console.WriteLine(e.ToString()); | ||
166 | CloseCommand(cmd); | ||
167 | return false; | ||
168 | } | ||
169 | } | ||
170 | |||
171 | else | ||
172 | { | ||
173 | string insert = "insert into `" + m_Realm + "` (`UUID`, `" + | ||
174 | String.Join("`, `", fields) + | ||
175 | "`) values (:UUID, :" + String.Join(", :", fields) + ")"; | ||
176 | |||
177 | cmd.Parameters.Add(new SqliteParameter(":UUID", data.PrincipalID.ToString())); | ||
178 | foreach (string field in fields) | ||
179 | cmd.Parameters.Add(new SqliteParameter(":" + field, data.Data[field])); | ||
180 | |||
181 | cmd.CommandText = insert; | ||
182 | |||
183 | try | ||
184 | { | ||
185 | if (ExecuteNonQuery(cmd, m_Connection) < 1) | ||
186 | { | ||
187 | CloseCommand(cmd); | ||
188 | return false; | ||
189 | } | ||
190 | } | ||
191 | catch (Exception e) | ||
192 | { | ||
193 | Console.WriteLine(e.ToString()); | ||
194 | CloseCommand(cmd); | ||
195 | return false; | ||
196 | } | ||
197 | } | ||
198 | |||
199 | CloseCommand(cmd); | ||
200 | |||
201 | return true; | ||
202 | } | ||
203 | |||
204 | public bool SetDataItem(UUID principalID, string item, string value) | ||
205 | { | ||
206 | SqliteCommand cmd = new SqliteCommand("update `" + m_Realm + | ||
207 | "` set `" + item + "` = " + value + " where UUID = '" + principalID.ToString() + "'"); | ||
208 | |||
209 | if (ExecuteNonQuery(cmd, m_Connection) > 0) | ||
210 | return true; | ||
211 | |||
212 | return false; | ||
213 | } | ||
214 | |||
215 | public bool SetToken(UUID principalID, string token, int lifetime) | ||
216 | { | ||
217 | if (System.Environment.TickCount - m_LastExpire > 30000) | ||
218 | DoExpire(); | ||
219 | |||
220 | SqliteCommand cmd = new SqliteCommand("insert into tokens (UUID, token, validity) values ('" + principalID.ToString() + | ||
221 | "', '" + token + "', datetime('now', 'localtime', '+" + lifetime.ToString() + " minutes'))"); | ||
222 | |||
223 | if (ExecuteNonQuery(cmd, m_Connection) > 0) | ||
224 | { | ||
225 | cmd.Dispose(); | ||
226 | return true; | ||
227 | } | ||
228 | |||
229 | cmd.Dispose(); | ||
230 | return false; | ||
231 | } | ||
232 | |||
233 | public bool CheckToken(UUID principalID, string token, int lifetime) | ||
234 | { | ||
235 | if (System.Environment.TickCount - m_LastExpire > 30000) | ||
236 | DoExpire(); | ||
237 | |||
238 | SqliteCommand cmd = new SqliteCommand("update tokens set validity = datetime('now, 'localtime', '+" + lifetime.ToString() + | ||
239 | " minutes') where UUID = '" + principalID.ToString() + "' and token = '" + token + "' and validity > datetime('now', 'localtime')"); | ||
240 | |||
241 | if (ExecuteNonQuery(cmd, m_Connection) > 0) | ||
242 | { | ||
243 | cmd.Dispose(); | ||
244 | return true; | ||
245 | } | ||
246 | |||
247 | cmd.Dispose(); | ||
248 | |||
249 | return false; | ||
250 | } | ||
251 | |||
252 | private void DoExpire() | ||
253 | { | ||
254 | SqliteCommand cmd = new SqliteCommand("delete from tokens where validity < datetime('now', 'localtime')"); | ||
255 | ExecuteNonQuery(cmd, m_Connection); | ||
256 | |||
257 | cmd.Dispose(); | ||
258 | |||
259 | m_LastExpire = System.Environment.TickCount; | ||
260 | } | ||
261 | } | ||
262 | } | ||
diff --git a/OpenSim/Data/SQLite/Tests/SQLiteUserTest.cs b/OpenSim/Data/SQLite/SQLiteAvatarData.cs index c9953c5..d0b82de 100644 --- a/OpenSim/Data/SQLite/Tests/SQLiteUserTest.cs +++ b/OpenSim/Data/SQLite/SQLiteAvatarData.cs | |||
@@ -25,40 +25,50 @@ | |||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System.IO; | 28 | using System; |
29 | using NUnit.Framework; | 29 | using System.Collections.Generic; |
30 | using OpenSim.Data.Tests; | 30 | using System.Data; |
31 | using OpenSim.Tests.Common; | 31 | using System.Reflection; |
32 | using System.Threading; | ||
33 | using log4net; | ||
34 | using OpenMetaverse; | ||
35 | using OpenSim.Framework; | ||
36 | using Mono.Data.SqliteClient; | ||
32 | 37 | ||
33 | namespace OpenSim.Data.SQLite.Tests | 38 | namespace OpenSim.Data.SQLite |
34 | { | 39 | { |
35 | [TestFixture, DatabaseTest] | 40 | /// <summary> |
36 | public class SQLiteUserTest : BasicUserTest | 41 | /// A MySQL Interface for the Grid Server |
42 | /// </summary> | ||
43 | public class SQLiteAvatarData : SQLiteGenericTableHandler<AvatarBaseData>, | ||
44 | IAvatarData | ||
37 | { | 45 | { |
38 | public string file; | 46 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
39 | public string connect; | ||
40 | |||
41 | [TestFixtureSetUp] | ||
42 | public void Init() | ||
43 | { | ||
44 | // SQLite doesn't work on power or z linux | ||
45 | if (Directory.Exists("/proc/ppc64") || Directory.Exists("/proc/dasd")) | ||
46 | { | ||
47 | Assert.Ignore(); | ||
48 | } | ||
49 | 47 | ||
50 | SuperInit(); | 48 | public SQLiteAvatarData(string connectionString, string realm) : |
51 | file = Path.GetTempFileName() + ".db"; | 49 | base(connectionString, realm, "Avatar") |
52 | connect = "URI=file:" + file + ",version=3"; | 50 | { |
53 | db = new SQLiteUserData(); | ||
54 | db.Initialise(connect); | ||
55 | } | 51 | } |
56 | 52 | ||
57 | [TestFixtureTearDown] | 53 | public bool Delete(UUID principalID, string name) |
58 | public void Cleanup() | ||
59 | { | 54 | { |
60 | db.Dispose(); | 55 | SqliteCommand cmd = new SqliteCommand(); |
61 | File.Delete(file); | 56 | |
57 | cmd.CommandText = String.Format("delete from {0} where `PrincipalID` = :PrincipalID and `Name` = :Name", m_Realm); | ||
58 | cmd.Parameters.Add(":PrincipalID", principalID.ToString()); | ||
59 | cmd.Parameters.Add(":Name", name); | ||
60 | |||
61 | try | ||
62 | { | ||
63 | if (ExecuteNonQuery(cmd, m_Connection) > 0) | ||
64 | return true; | ||
65 | |||
66 | return false; | ||
67 | } | ||
68 | finally | ||
69 | { | ||
70 | CloseCommand(cmd); | ||
71 | } | ||
62 | } | 72 | } |
63 | } | 73 | } |
64 | } | 74 | } |
diff --git a/OpenSim/Data/SQLite/SQLiteFramework.cs b/OpenSim/Data/SQLite/SQLiteFramework.cs index 12b2750..20b5085 100644 --- a/OpenSim/Data/SQLite/SQLiteFramework.cs +++ b/OpenSim/Data/SQLite/SQLiteFramework.cs | |||
@@ -40,12 +40,10 @@ namespace OpenSim.Data.SQLite | |||
40 | /// </summary> | 40 | /// </summary> |
41 | public class SQLiteFramework | 41 | public class SQLiteFramework |
42 | { | 42 | { |
43 | protected SqliteConnection m_Connection; | 43 | protected Object m_lockObject = new Object(); |
44 | 44 | ||
45 | protected SQLiteFramework(string connectionString) | 45 | protected SQLiteFramework(string connectionString) |
46 | { | 46 | { |
47 | m_Connection = new SqliteConnection(connectionString); | ||
48 | m_Connection.Open(); | ||
49 | } | 47 | } |
50 | 48 | ||
51 | ////////////////////////////////////////////////////////////// | 49 | ////////////////////////////////////////////////////////////// |
@@ -53,27 +51,37 @@ namespace OpenSim.Data.SQLite | |||
53 | // All non queries are funneled through one connection | 51 | // All non queries are funneled through one connection |
54 | // to increase performance a little | 52 | // to increase performance a little |
55 | // | 53 | // |
56 | protected int ExecuteNonQuery(SqliteCommand cmd) | 54 | protected int ExecuteNonQuery(SqliteCommand cmd, SqliteConnection connection) |
57 | { | 55 | { |
58 | lock (m_Connection) | 56 | lock (connection) |
59 | { | 57 | { |
60 | cmd.Connection = m_Connection; | 58 | SqliteConnection newConnection = |
59 | (SqliteConnection)((ICloneable)connection).Clone(); | ||
60 | newConnection.Open(); | ||
61 | |||
62 | cmd.Connection = newConnection; | ||
63 | //Console.WriteLine("XXX " + cmd.CommandText); | ||
61 | 64 | ||
62 | return cmd.ExecuteNonQuery(); | 65 | return cmd.ExecuteNonQuery(); |
63 | } | 66 | } |
64 | } | 67 | } |
65 | 68 | ||
66 | protected IDataReader ExecuteReader(SqliteCommand cmd) | 69 | protected IDataReader ExecuteReader(SqliteCommand cmd, SqliteConnection connection) |
67 | { | 70 | { |
68 | SqliteConnection newConnection = | 71 | lock (connection) |
69 | (SqliteConnection)((ICloneable)m_Connection).Clone(); | 72 | { |
70 | newConnection.Open(); | 73 | SqliteConnection newConnection = |
74 | (SqliteConnection)((ICloneable)connection).Clone(); | ||
75 | newConnection.Open(); | ||
71 | 76 | ||
72 | cmd.Connection = newConnection; | 77 | cmd.Connection = newConnection; |
73 | return cmd.ExecuteReader(); | 78 | //Console.WriteLine("XXX " + cmd.CommandText); |
79 | |||
80 | return cmd.ExecuteReader(); | ||
81 | } | ||
74 | } | 82 | } |
75 | 83 | ||
76 | protected void CloseReaderCommand(SqliteCommand cmd) | 84 | protected void CloseCommand(SqliteCommand cmd) |
77 | { | 85 | { |
78 | cmd.Connection.Close(); | 86 | cmd.Connection.Close(); |
79 | cmd.Connection.Dispose(); | 87 | cmd.Connection.Dispose(); |
diff --git a/OpenSim/Data/SQLite/SQLiteGenericTableHandler.cs b/OpenSim/Data/SQLite/SQLiteGenericTableHandler.cs index 8e91693..b39bb19 100644 --- a/OpenSim/Data/SQLite/SQLiteGenericTableHandler.cs +++ b/OpenSim/Data/SQLite/SQLiteGenericTableHandler.cs | |||
@@ -48,16 +48,33 @@ namespace OpenSim.Data.SQLite | |||
48 | protected string m_Realm; | 48 | protected string m_Realm; |
49 | protected FieldInfo m_DataField = null; | 49 | protected FieldInfo m_DataField = null; |
50 | 50 | ||
51 | protected static SqliteConnection m_Connection; | ||
52 | private static bool m_initialized; | ||
53 | |||
51 | public SQLiteGenericTableHandler(string connectionString, | 54 | public SQLiteGenericTableHandler(string connectionString, |
52 | string realm, string storeName) : base(connectionString) | 55 | string realm, string storeName) : base(connectionString) |
53 | { | 56 | { |
54 | m_Realm = realm; | 57 | m_Realm = realm; |
55 | if (storeName != String.Empty) | 58 | |
59 | if (!m_initialized) | ||
56 | { | 60 | { |
57 | Assembly assem = GetType().Assembly; | 61 | m_Connection = new SqliteConnection(connectionString); |
62 | m_Connection.Open(); | ||
63 | |||
64 | if (storeName != String.Empty) | ||
65 | { | ||
66 | Assembly assem = GetType().Assembly; | ||
67 | SqliteConnection newConnection = | ||
68 | (SqliteConnection)((ICloneable)m_Connection).Clone(); | ||
69 | newConnection.Open(); | ||
70 | |||
71 | Migration m = new Migration(newConnection, assem, storeName); | ||
72 | m.Update(); | ||
73 | newConnection.Close(); | ||
74 | newConnection.Dispose(); | ||
75 | } | ||
58 | 76 | ||
59 | Migration m = new Migration(m_Connection, assem, storeName); | 77 | m_initialized = true; |
60 | m.Update(); | ||
61 | } | 78 | } |
62 | 79 | ||
63 | Type t = typeof(T); | 80 | Type t = typeof(T); |
@@ -125,7 +142,7 @@ namespace OpenSim.Data.SQLite | |||
125 | 142 | ||
126 | protected T[] DoQuery(SqliteCommand cmd) | 143 | protected T[] DoQuery(SqliteCommand cmd) |
127 | { | 144 | { |
128 | IDataReader reader = ExecuteReader(cmd); | 145 | IDataReader reader = ExecuteReader(cmd, m_Connection); |
129 | if (reader == null) | 146 | if (reader == null) |
130 | return new T[0]; | 147 | return new T[0]; |
131 | 148 | ||
@@ -180,7 +197,7 @@ namespace OpenSim.Data.SQLite | |||
180 | result.Add(row); | 197 | result.Add(row); |
181 | } | 198 | } |
182 | 199 | ||
183 | CloseReaderCommand(cmd); | 200 | CloseCommand(cmd); |
184 | 201 | ||
185 | return result.ToArray(); | 202 | return result.ToArray(); |
186 | } | 203 | } |
@@ -229,7 +246,7 @@ namespace OpenSim.Data.SQLite | |||
229 | 246 | ||
230 | cmd.CommandText = query; | 247 | cmd.CommandText = query; |
231 | 248 | ||
232 | if (ExecuteNonQuery(cmd) > 0) | 249 | if (ExecuteNonQuery(cmd, m_Connection) > 0) |
233 | return true; | 250 | return true; |
234 | 251 | ||
235 | return false; | 252 | return false; |
@@ -242,7 +259,7 @@ namespace OpenSim.Data.SQLite | |||
242 | cmd.CommandText = String.Format("delete from {0} where `{1}` = :{1}", m_Realm, field); | 259 | cmd.CommandText = String.Format("delete from {0} where `{1}` = :{1}", m_Realm, field); |
243 | cmd.Parameters.Add(new SqliteParameter(field, val)); | 260 | cmd.Parameters.Add(new SqliteParameter(field, val)); |
244 | 261 | ||
245 | if (ExecuteNonQuery(cmd) > 0) | 262 | if (ExecuteNonQuery(cmd, m_Connection) > 0) |
246 | return true; | 263 | return true; |
247 | 264 | ||
248 | return false; | 265 | return false; |
diff --git a/OpenSim/Data/SQLite/SQLiteGridData.cs b/OpenSim/Data/SQLite/SQLiteGridData.cs deleted file mode 100644 index 18abb88..0000000 --- a/OpenSim/Data/SQLite/SQLiteGridData.cs +++ /dev/null | |||
@@ -1,286 +0,0 @@ | |||
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.Data; | ||
31 | using System.Reflection; | ||
32 | using log4net; | ||
33 | using OpenMetaverse; | ||
34 | using OpenSim.Framework; | ||
35 | |||
36 | namespace OpenSim.Data.SQLite | ||
37 | { | ||
38 | /// <summary> | ||
39 | /// A Grid Interface to the SQLite database | ||
40 | /// </summary> | ||
41 | public class SQLiteGridData : GridDataBase | ||
42 | { | ||
43 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
44 | |||
45 | /// <summary> | ||
46 | /// SQLite database manager | ||
47 | /// </summary> | ||
48 | private SQLiteManager database; | ||
49 | |||
50 | override public void Initialise() | ||
51 | { | ||
52 | m_log.Info("[SQLite]: " + Name + " cannot be default-initialized!"); | ||
53 | throw new PluginNotInitialisedException (Name); | ||
54 | } | ||
55 | |||
56 | /// <summary> | ||
57 | /// <list type="bullet"> | ||
58 | /// <item>Initialises Inventory interface</item> | ||
59 | /// <item>Loads and initialises a new SQLite connection and maintains it.</item> | ||
60 | /// <item>use default URI if connect string is empty.</item> | ||
61 | /// </list> | ||
62 | /// </summary> | ||
63 | /// <param name="dbconnect">connect string</param> | ||
64 | override public void Initialise(string connect) | ||
65 | { | ||
66 | database = new SQLiteManager(connect); | ||
67 | } | ||
68 | |||
69 | /// <summary> | ||
70 | /// Shuts down the grid interface | ||
71 | /// </summary> | ||
72 | override public void Dispose() | ||
73 | { | ||
74 | database.Close(); | ||
75 | } | ||
76 | |||
77 | /// <summary> | ||
78 | /// Returns the name of this grid interface | ||
79 | /// </summary> | ||
80 | /// <returns>A string containing the grid interface</returns> | ||
81 | override public string Name | ||
82 | { | ||
83 | get { return "SQLite OpenGridData"; } | ||
84 | } | ||
85 | |||
86 | /// <summary> | ||
87 | /// Returns the version of this grid interface | ||
88 | /// </summary> | ||
89 | /// <returns>A string containing the version</returns> | ||
90 | override public string Version | ||
91 | { | ||
92 | get { return "0.1"; } | ||
93 | } | ||
94 | |||
95 | /// <summary> | ||
96 | /// Returns a list of regions within the specified ranges | ||
97 | /// </summary> | ||
98 | /// <param name="a">minimum X coordinate</param> | ||
99 | /// <param name="b">minimum Y coordinate</param> | ||
100 | /// <param name="c">maximum X coordinate</param> | ||
101 | /// <param name="d">maximum Y coordinate</param> | ||
102 | /// <returns>An array of region profiles</returns> | ||
103 | /// <remarks>NOT IMPLEMENTED ? always return null</remarks> | ||
104 | override public RegionProfileData[] GetProfilesInRange(uint a, uint b, uint c, uint d) | ||
105 | { | ||
106 | return null; | ||
107 | } | ||
108 | |||
109 | |||
110 | /// <summary> | ||
111 | /// Returns up to maxNum profiles of regions that have a name starting with namePrefix | ||
112 | /// </summary> | ||
113 | /// <param name="name">The name to match against</param> | ||
114 | /// <param name="maxNum">Maximum number of profiles to return</param> | ||
115 | /// <returns>A list of sim profiles</returns> | ||
116 | override public List<RegionProfileData> GetRegionsByName (string namePrefix, uint maxNum) | ||
117 | { | ||
118 | return null; | ||
119 | } | ||
120 | |||
121 | /// <summary> | ||
122 | /// Returns a sim profile from it's handle | ||
123 | /// </summary> | ||
124 | /// <param name="handle">Region location handle</param> | ||
125 | /// <returns>Sim profile</returns> | ||
126 | override public RegionProfileData GetProfileByHandle(ulong handle) | ||
127 | { | ||
128 | Dictionary<string, string> param = new Dictionary<string, string>(); | ||
129 | param["handle"] = handle.ToString(); | ||
130 | |||
131 | IDbCommand result = database.Query("SELECT * FROM regions WHERE handle = @handle", param); | ||
132 | IDataReader reader = result.ExecuteReader(); | ||
133 | |||
134 | RegionProfileData row = database.getRow(reader); | ||
135 | reader.Close(); | ||
136 | result.Dispose(); | ||
137 | |||
138 | return row; | ||
139 | } | ||
140 | |||
141 | /// <summary> | ||
142 | /// Returns a sim profile from it's Region name string | ||
143 | /// </summary> | ||
144 | /// <param name="regionName">The region name search query</param> | ||
145 | /// <returns>The sim profile</returns> | ||
146 | override public RegionProfileData GetProfileByString(string regionName) | ||
147 | { | ||
148 | if (regionName.Length > 2) | ||
149 | { | ||
150 | Dictionary<string, string> param = new Dictionary<string, string>(); | ||
151 | // Add % because this is a like query. | ||
152 | param["?regionName"] = regionName + "%"; | ||
153 | // Only returns one record or no record. | ||
154 | IDbCommand result = database.Query("SELECT * FROM regions WHERE regionName like ?regionName LIMIT 1", param); | ||
155 | IDataReader reader = result.ExecuteReader(); | ||
156 | |||
157 | RegionProfileData row = database.getRow(reader); | ||
158 | reader.Close(); | ||
159 | result.Dispose(); | ||
160 | |||
161 | return row; | ||
162 | } | ||
163 | else | ||
164 | { | ||
165 | //m_log.Error("[DATABASE]: Searched for a Region Name shorter then 3 characters"); | ||
166 | return null; | ||
167 | } | ||
168 | } | ||
169 | |||
170 | /// <summary> | ||
171 | /// Returns a sim profile from it's UUID | ||
172 | /// </summary> | ||
173 | /// <param name="uuid">The region UUID</param> | ||
174 | /// <returns>The sim profile</returns> | ||
175 | override public RegionProfileData GetProfileByUUID(UUID uuid) | ||
176 | { | ||
177 | Dictionary<string, string> param = new Dictionary<string, string>(); | ||
178 | param["uuid"] = uuid.ToString(); | ||
179 | |||
180 | IDbCommand result = database.Query("SELECT * FROM regions WHERE uuid = @uuid", param); | ||
181 | IDataReader reader = result.ExecuteReader(); | ||
182 | |||
183 | RegionProfileData row = database.getRow(reader); | ||
184 | reader.Close(); | ||
185 | result.Dispose(); | ||
186 | |||
187 | return row; | ||
188 | } | ||
189 | |||
190 | /// <summary> | ||
191 | /// Returns a list of avatar and UUIDs that match the query | ||
192 | /// </summary> | ||
193 | /// <remarks>do nothing yet</remarks> | ||
194 | public List<AvatarPickerAvatar> GeneratePickerResults(UUID queryID, string query) | ||
195 | { | ||
196 | //Do nothing yet | ||
197 | List<AvatarPickerAvatar> returnlist = new List<AvatarPickerAvatar>(); | ||
198 | return returnlist; | ||
199 | } | ||
200 | |||
201 | /// <summary> | ||
202 | /// Adds a new specified region to the database | ||
203 | /// </summary> | ||
204 | /// <param name="profile">The profile to add</param> | ||
205 | /// <returns>A dataresponse enum indicating success</returns> | ||
206 | override public DataResponse StoreProfile(RegionProfileData profile) | ||
207 | { | ||
208 | if (database.insertRow(profile)) | ||
209 | { | ||
210 | return DataResponse.RESPONSE_OK; | ||
211 | } | ||
212 | else | ||
213 | { | ||
214 | return DataResponse.RESPONSE_ERROR; | ||
215 | } | ||
216 | } | ||
217 | |||
218 | /// <summary> | ||
219 | /// Deletes a sim profile from the database | ||
220 | /// </summary> | ||
221 | /// <param name="uuid">the sim UUID</param> | ||
222 | /// <returns>Successful?</returns> | ||
223 | override public DataResponse DeleteProfile(string uuid) | ||
224 | { | ||
225 | Dictionary<string, string> param = new Dictionary<string, string>(); | ||
226 | param["uuid"] = uuid; | ||
227 | |||
228 | IDbCommand result = database.Query("DELETE FROM regions WHERE uuid = @uuid", param); | ||
229 | if (result.ExecuteNonQuery() > 0) | ||
230 | { | ||
231 | return DataResponse.RESPONSE_OK; | ||
232 | } | ||
233 | return DataResponse.RESPONSE_ERROR; | ||
234 | } | ||
235 | |||
236 | /// <summary> | ||
237 | /// DEPRECATED. Attempts to authenticate a region by comparing a shared secret. | ||
238 | /// </summary> | ||
239 | /// <param name="uuid">The UUID of the challenger</param> | ||
240 | /// <param name="handle">The attempted regionHandle of the challenger</param> | ||
241 | /// <param name="authkey">The secret</param> | ||
242 | /// <returns>Whether the secret and regionhandle match the database entry for UUID</returns> | ||
243 | override public bool AuthenticateSim(UUID uuid, ulong handle, string authkey) | ||
244 | { | ||
245 | bool throwHissyFit = false; // Should be true by 1.0 | ||
246 | |||
247 | if (throwHissyFit) | ||
248 | throw new Exception("CRYPTOWEAK AUTHENTICATE: Refusing to authenticate due to replay potential."); | ||
249 | |||
250 | RegionProfileData data = GetProfileByUUID(uuid); | ||
251 | |||
252 | return (handle == data.regionHandle && authkey == data.regionSecret); | ||
253 | } | ||
254 | |||
255 | /// <summary> | ||
256 | /// NOT YET FUNCTIONAL. Provides a cryptographic authentication of a region | ||
257 | /// </summary> | ||
258 | /// <remarks>This requires a security audit.</remarks> | ||
259 | /// <param name="uuid"></param> | ||
260 | /// <param name="handle"></param> | ||
261 | /// <param name="authhash"></param> | ||
262 | /// <param name="challenge"></param> | ||
263 | /// <returns></returns> | ||
264 | public bool AuthenticateSim(UUID uuid, ulong handle, string authhash, string challenge) | ||
265 | { | ||
266 | // SHA512Managed HashProvider = new SHA512Managed(); | ||
267 | // Encoding TextProvider = new UTF8Encoding(); | ||
268 | |||
269 | // byte[] stream = TextProvider.GetBytes(uuid.ToString() + ":" + handle.ToString() + ":" + challenge); | ||
270 | // byte[] hash = HashProvider.ComputeHash(stream); | ||
271 | |||
272 | return false; | ||
273 | } | ||
274 | |||
275 | /// <summary> | ||
276 | /// NOT IMPLEMENTED | ||
277 | /// </summary> | ||
278 | /// <param name="x">x coordinate</param> | ||
279 | /// <param name="y">y coordinate</param> | ||
280 | /// <returns>always return null</returns> | ||
281 | override public ReservationData GetReservationAtPoint(uint x, uint y) | ||
282 | { | ||
283 | return null; | ||
284 | } | ||
285 | } | ||
286 | } | ||
diff --git a/OpenSim/Data/SQLite/SQLiteManager.cs b/OpenSim/Data/SQLite/SQLiteManager.cs deleted file mode 100644 index b6d4a1c..0000000 --- a/OpenSim/Data/SQLite/SQLiteManager.cs +++ /dev/null | |||
@@ -1,225 +0,0 @@ | |||
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.Data; | ||
31 | using System.Data.SQLite; | ||
32 | using System.Reflection; | ||
33 | using log4net; | ||
34 | using OpenMetaverse; | ||
35 | |||
36 | namespace OpenSim.Data.SQLite | ||
37 | { | ||
38 | /// <summary> | ||
39 | /// SQLite Manager | ||
40 | /// </summary> | ||
41 | internal class SQLiteManager : SQLiteUtil | ||
42 | { | ||
43 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
44 | |||
45 | private IDbConnection dbcon; | ||
46 | |||
47 | /// <summary> | ||
48 | /// <list type="bullet"> | ||
49 | /// <item>Initialises and creates a new SQLite connection and maintains it.</item> | ||
50 | /// <item>use default URI if connect string is empty.</item> | ||
51 | /// </list> | ||
52 | /// </summary> | ||
53 | /// <param name="connect">connect string</param> | ||
54 | public SQLiteManager(string connect) | ||
55 | { | ||
56 | try | ||
57 | { | ||
58 | string connectionString = String.Empty; | ||
59 | if (connect != String.Empty) | ||
60 | { | ||
61 | connectionString = connect; | ||
62 | } | ||
63 | else | ||
64 | { | ||
65 | m_log.Warn("[SQLITE] grid db not specified, using default"); | ||
66 | connectionString = "URI=file:GridServerSqlite.db;"; | ||
67 | } | ||
68 | |||
69 | dbcon = new SQLiteConnection(connectionString); | ||
70 | |||
71 | dbcon.Open(); | ||
72 | } | ||
73 | catch (Exception e) | ||
74 | { | ||
75 | throw new Exception("Error initialising SQLite Database: " + e.ToString()); | ||
76 | } | ||
77 | } | ||
78 | |||
79 | /// <summary> | ||
80 | /// Shuts down the database connection | ||
81 | /// </summary> | ||
82 | public void Close() | ||
83 | { | ||
84 | dbcon.Close(); | ||
85 | dbcon = null; | ||
86 | } | ||
87 | |||
88 | /// <summary> | ||
89 | /// Runs a query with protection against SQL Injection by using parameterised input. | ||
90 | /// </summary> | ||
91 | /// <param name="sql">The SQL string - replace any variables such as WHERE x = "y" with WHERE x = @y</param> | ||
92 | /// <param name="parameters">The parameters - index so that @y is indexed as 'y'</param> | ||
93 | /// <returns>A SQLite DB Command</returns> | ||
94 | public IDbCommand Query(string sql, Dictionary<string, string> parameters) | ||
95 | { | ||
96 | SQLiteCommand dbcommand = (SQLiteCommand) dbcon.CreateCommand(); | ||
97 | dbcommand.CommandText = sql; | ||
98 | foreach (KeyValuePair<string, string> param in parameters) | ||
99 | { | ||
100 | SQLiteParameter paramx = new SQLiteParameter(param.Key, param.Value); | ||
101 | dbcommand.Parameters.Add(paramx); | ||
102 | } | ||
103 | |||
104 | return (IDbCommand) dbcommand; | ||
105 | } | ||
106 | |||
107 | /// <summary> | ||
108 | /// Reads a region row from a database reader | ||
109 | /// </summary> | ||
110 | /// <param name="reader">An active database reader</param> | ||
111 | /// <returns>A region profile</returns> | ||
112 | public RegionProfileData getRow(IDataReader reader) | ||
113 | { | ||
114 | RegionProfileData retval = new RegionProfileData(); | ||
115 | |||
116 | if (reader.Read()) | ||
117 | { | ||
118 | // Region Main | ||
119 | retval.regionHandle = (ulong) reader["regionHandle"]; | ||
120 | retval.regionName = (string) reader["regionName"]; | ||
121 | retval.UUID = new UUID((string) reader["uuid"]); | ||
122 | |||
123 | // Secrets | ||
124 | retval.regionRecvKey = (string) reader["regionRecvKey"]; | ||
125 | retval.regionSecret = (string) reader["regionSecret"]; | ||
126 | retval.regionSendKey = (string) reader["regionSendKey"]; | ||
127 | |||
128 | // Region Server | ||
129 | retval.regionDataURI = (string) reader["regionDataURI"]; | ||
130 | retval.regionOnline = false; // Needs to be pinged before this can be set. | ||
131 | retval.serverIP = (string) reader["serverIP"]; | ||
132 | retval.serverPort = (uint) reader["serverPort"]; | ||
133 | retval.serverURI = (string) reader["serverURI"]; | ||
134 | |||
135 | // Location | ||
136 | retval.regionLocX = (uint) ((int) reader["locX"]); | ||
137 | retval.regionLocY = (uint) ((int) reader["locY"]); | ||
138 | retval.regionLocZ = (uint) ((int) reader["locZ"]); | ||
139 | |||
140 | // Neighbours - 0 = No Override | ||
141 | retval.regionEastOverrideHandle = (ulong) reader["eastOverrideHandle"]; | ||
142 | retval.regionWestOverrideHandle = (ulong) reader["westOverrideHandle"]; | ||
143 | retval.regionSouthOverrideHandle = (ulong) reader["southOverrideHandle"]; | ||
144 | retval.regionNorthOverrideHandle = (ulong) reader["northOverrideHandle"]; | ||
145 | |||
146 | // Assets | ||
147 | retval.regionAssetURI = (string) reader["regionAssetURI"]; | ||
148 | retval.regionAssetRecvKey = (string) reader["regionAssetRecvKey"]; | ||
149 | retval.regionAssetSendKey = (string) reader["regionAssetSendKey"]; | ||
150 | |||
151 | // Userserver | ||
152 | retval.regionUserURI = (string) reader["regionUserURI"]; | ||
153 | retval.regionUserRecvKey = (string) reader["regionUserRecvKey"]; | ||
154 | retval.regionUserSendKey = (string) reader["regionUserSendKey"]; | ||
155 | } | ||
156 | else | ||
157 | { | ||
158 | throw new Exception("No rows to return"); | ||
159 | } | ||
160 | return retval; | ||
161 | } | ||
162 | |||
163 | /// <summary> | ||
164 | /// Inserts a new region into the database | ||
165 | /// </summary> | ||
166 | /// <param name="profile">The region to insert</param> | ||
167 | /// <returns>Success?</returns> | ||
168 | public bool insertRow(RegionProfileData profile) | ||
169 | { | ||
170 | string sql = | ||
171 | "REPLACE INTO regions VALUES (regionHandle, regionName, uuid, regionRecvKey, regionSecret, regionSendKey, regionDataURI, "; | ||
172 | sql += | ||
173 | "serverIP, serverPort, serverURI, locX, locY, locZ, eastOverrideHandle, westOverrideHandle, southOverrideHandle, northOverrideHandle, regionAssetURI, regionAssetRecvKey, "; | ||
174 | sql += "regionAssetSendKey, regionUserURI, regionUserRecvKey, regionUserSendKey) VALUES "; | ||
175 | |||
176 | sql += "(@regionHandle, @regionName, @uuid, @regionRecvKey, @regionSecret, @regionSendKey, @regionDataURI, "; | ||
177 | sql += | ||
178 | "@serverIP, @serverPort, @serverURI, @locX, @locY, @locZ, @eastOverrideHandle, @westOverrideHandle, @southOverrideHandle, @northOverrideHandle, @regionAssetURI, @regionAssetRecvKey, "; | ||
179 | sql += "@regionAssetSendKey, @regionUserURI, @regionUserRecvKey, @regionUserSendKey);"; | ||
180 | |||
181 | Dictionary<string, string> parameters = new Dictionary<string, string>(); | ||
182 | |||
183 | parameters["regionHandle"] = profile.regionHandle.ToString(); | ||
184 | parameters["regionName"] = profile.regionName; | ||
185 | parameters["uuid"] = profile.UUID.ToString(); | ||
186 | parameters["regionRecvKey"] = profile.regionRecvKey; | ||
187 | parameters["regionSendKey"] = profile.regionSendKey; | ||
188 | parameters["regionDataURI"] = profile.regionDataURI; | ||
189 | parameters["serverIP"] = profile.serverIP; | ||
190 | parameters["serverPort"] = profile.serverPort.ToString(); | ||
191 | parameters["serverURI"] = profile.serverURI; | ||
192 | parameters["locX"] = profile.regionLocX.ToString(); | ||
193 | parameters["locY"] = profile.regionLocY.ToString(); | ||
194 | parameters["locZ"] = profile.regionLocZ.ToString(); | ||
195 | parameters["eastOverrideHandle"] = profile.regionEastOverrideHandle.ToString(); | ||
196 | parameters["westOverrideHandle"] = profile.regionWestOverrideHandle.ToString(); | ||
197 | parameters["northOverrideHandle"] = profile.regionNorthOverrideHandle.ToString(); | ||
198 | parameters["southOverrideHandle"] = profile.regionSouthOverrideHandle.ToString(); | ||
199 | parameters["regionAssetURI"] = profile.regionAssetURI; | ||
200 | parameters["regionAssetRecvKey"] = profile.regionAssetRecvKey; | ||
201 | parameters["regionAssetSendKey"] = profile.regionAssetSendKey; | ||
202 | parameters["regionUserURI"] = profile.regionUserURI; | ||
203 | parameters["regionUserRecvKey"] = profile.regionUserRecvKey; | ||
204 | parameters["regionUserSendKey"] = profile.regionUserSendKey; | ||
205 | |||
206 | bool returnval = false; | ||
207 | |||
208 | try | ||
209 | { | ||
210 | IDbCommand result = Query(sql, parameters); | ||
211 | |||
212 | if (result.ExecuteNonQuery() == 1) | ||
213 | returnval = true; | ||
214 | |||
215 | result.Dispose(); | ||
216 | } | ||
217 | catch (Exception) | ||
218 | { | ||
219 | return false; | ||
220 | } | ||
221 | |||
222 | return returnval; | ||
223 | } | ||
224 | } | ||
225 | } | ||
diff --git a/OpenSim/Data/MySQL/Tests/MySQLUserTest.cs b/OpenSim/Data/SQLite/SQLiteUserAccountData.cs index cf8139a..50e8c23 100644 --- a/OpenSim/Data/MySQL/Tests/MySQLUserTest.cs +++ b/OpenSim/Data/SQLite/SQLiteUserAccountData.cs | |||
@@ -26,60 +26,56 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using NUnit.Framework; | 29 | using System.Collections; |
30 | using OpenSim.Data.Tests; | 30 | using System.Collections.Generic; |
31 | using log4net; | 31 | using System.Data; |
32 | using System.Reflection; | 32 | using OpenMetaverse; |
33 | using OpenSim.Tests.Common; | 33 | using OpenSim.Framework; |
34 | using Mono.Data.SqliteClient; | ||
34 | 35 | ||
35 | namespace OpenSim.Data.MySQL.Tests | 36 | namespace OpenSim.Data.SQLite |
36 | { | 37 | { |
37 | [TestFixture, DatabaseTest] | 38 | public class SQLiteUserAccountData : SQLiteGenericTableHandler<UserAccountData>, IUserAccountData |
38 | public class MySQLUserTest : BasicUserTest | ||
39 | { | 39 | { |
40 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 40 | public SQLiteUserAccountData(string connectionString, string realm) |
41 | public string file; | 41 | : base(connectionString, realm, "UserAccount") |
42 | public MySQLManager database; | ||
43 | public string connect = "Server=localhost;Port=3306;Database=opensim-nunit;User ID=opensim-nunit;Password=opensim-nunit;Pooling=false;"; | ||
44 | |||
45 | [TestFixtureSetUp] | ||
46 | public void Init() | ||
47 | { | 42 | { |
48 | SuperInit(); | ||
49 | // If we manage to connect to the database with the user | ||
50 | // and password above it is our test database, and run | ||
51 | // these tests. If anything goes wrong, ignore these | ||
52 | // tests. | ||
53 | try | ||
54 | { | ||
55 | database = new MySQLManager(connect); | ||
56 | db = new MySQLUserData(); | ||
57 | db.Initialise(connect); | ||
58 | } | ||
59 | catch (Exception e) | ||
60 | { | ||
61 | m_log.Error("Exception {0}", e); | ||
62 | Assert.Ignore(); | ||
63 | } | ||
64 | } | 43 | } |
65 | 44 | ||
66 | [TestFixtureTearDown] | 45 | public UserAccountData[] GetUsers(UUID scopeID, string query) |
67 | public void Cleanup() | ||
68 | { | 46 | { |
69 | if (db != null) | 47 | string[] words = query.Split(new char[] {' '}); |
48 | |||
49 | for (int i = 0 ; i < words.Length ; i++) | ||
70 | { | 50 | { |
71 | db.Dispose(); | 51 | if (words[i].Length < 3) |
52 | { | ||
53 | if (i != words.Length - 1) | ||
54 | Array.Copy(words, i + 1, words, i, words.Length - i - 1); | ||
55 | Array.Resize(ref words, words.Length - 1); | ||
56 | } | ||
72 | } | 57 | } |
73 | // if a new table is added, it has to be dropped here | 58 | |
74 | if (database != null) | 59 | if (words.Length == 0) |
60 | return new UserAccountData[0]; | ||
61 | |||
62 | if (words.Length > 2) | ||
63 | return new UserAccountData[0]; | ||
64 | |||
65 | SqliteCommand cmd = new SqliteCommand(); | ||
66 | |||
67 | if (words.Length == 1) | ||
75 | { | 68 | { |
76 | database.ExecuteSql("drop table migrations"); | 69 | cmd.CommandText = String.Format("select * from {0} where ScopeID='{1}' or ScopeID='00000000-0000-0000-0000-000000000000') and (FirstName like '{2}%' or LastName like '{2}%')", |
77 | database.ExecuteSql("drop table users"); | 70 | m_Realm, scopeID.ToString(), words[0]); |
78 | database.ExecuteSql("drop table userfriends"); | ||
79 | database.ExecuteSql("drop table agents"); | ||
80 | database.ExecuteSql("drop table avatarappearance"); | ||
81 | database.ExecuteSql("drop table avatarattachments"); | ||
82 | } | 71 | } |
72 | else | ||
73 | { | ||
74 | cmd.CommandText = String.Format("select * from {0} where (ScopeID='{1}' or ScopeID='00000000-0000-0000-0000-000000000000') and (FirstName like '{2}%' or LastName like '{3}%')", | ||
75 | m_Realm, scopeID.ToString(), words[0], words[1]); | ||
76 | } | ||
77 | |||
78 | return DoQuery(cmd); | ||
83 | } | 79 | } |
84 | } | 80 | } |
85 | } | 81 | } |
diff --git a/OpenSim/Data/SQLite/SQLiteUserData.cs b/OpenSim/Data/SQLite/SQLiteUserData.cs deleted file mode 100644 index caddcf8..0000000 --- a/OpenSim/Data/SQLite/SQLiteUserData.cs +++ /dev/null | |||
@@ -1,1262 +0,0 @@ | |||
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.Data; | ||
31 | using System.Reflection; | ||
32 | using log4net; | ||
33 | using Mono.Data.SqliteClient; | ||
34 | using OpenMetaverse; | ||
35 | using OpenSim.Framework; | ||
36 | |||
37 | namespace OpenSim.Data.SQLite | ||
38 | { | ||
39 | /// <summary> | ||
40 | /// A User storage interface for the SQLite database system | ||
41 | /// </summary> | ||
42 | public class SQLiteUserData : UserDataBase | ||
43 | { | ||
44 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
45 | |||
46 | /// <summary> | ||
47 | /// The database manager | ||
48 | /// </summary> | ||
49 | /// <summary> | ||
50 | /// Artificial constructor called upon plugin load | ||
51 | /// </summary> | ||
52 | private const string SelectUserByUUID = "select * from users where UUID=:UUID"; | ||
53 | private const string SelectUserByName = "select * from users where username=:username and surname=:surname"; | ||
54 | private const string SelectFriendsByUUID = "select a.friendID, a.friendPerms, b.friendPerms from userfriends as a, userfriends as b where a.ownerID=:ownerID and b.ownerID=a.friendID and b.friendID=a.ownerID"; | ||
55 | |||
56 | private const string userSelect = "select * from users"; | ||
57 | private const string userFriendsSelect = "select a.ownerID as ownerID,a.friendID as friendID,a.friendPerms as friendPerms,b.friendPerms as ownerperms, b.ownerID as fownerID, b.friendID as ffriendID from userfriends as a, userfriends as b"; | ||
58 | private const string userAgentSelect = "select * from useragents"; | ||
59 | private const string AvatarAppearanceSelect = "select * from avatarappearance"; | ||
60 | |||
61 | private const string AvatarPickerAndSQL = "select * from users where username like :username and surname like :surname"; | ||
62 | private const string AvatarPickerOrSQL = "select * from users where username like :username or surname like :surname"; | ||
63 | |||
64 | private DataSet ds; | ||
65 | private SqliteDataAdapter da; | ||
66 | private SqliteDataAdapter daf; | ||
67 | private SqliteDataAdapter dua; | ||
68 | private SqliteDataAdapter daa; | ||
69 | SqliteConnection g_conn; | ||
70 | |||
71 | public override void Initialise() | ||
72 | { | ||
73 | m_log.Info("[SQLiteUserData]: " + Name + " cannot be default-initialized!"); | ||
74 | throw new PluginNotInitialisedException (Name); | ||
75 | } | ||
76 | |||
77 | /// <summary> | ||
78 | /// <list type="bullet"> | ||
79 | /// <item>Initialises User Interface</item> | ||
80 | /// <item>Loads and initialises a new SQLite connection and maintains it.</item> | ||
81 | /// <item>use default URI if connect string string is empty.</item> | ||
82 | /// </list> | ||
83 | /// </summary> | ||
84 | /// <param name="connect">connect string</param> | ||
85 | override public void Initialise(string connect) | ||
86 | { | ||
87 | // default to something sensible | ||
88 | if (connect == "") | ||
89 | connect = "URI=file:userprofiles.db,version=3"; | ||
90 | |||
91 | SqliteConnection conn = new SqliteConnection(connect); | ||
92 | |||
93 | // This sucks, but It doesn't seem to work with the dataset Syncing :P | ||
94 | g_conn = conn; | ||
95 | g_conn.Open(); | ||
96 | |||
97 | Assembly assem = GetType().Assembly; | ||
98 | Migration m = new Migration(g_conn, assem, "UserStore"); | ||
99 | m.Update(); | ||
100 | |||
101 | |||
102 | ds = new DataSet(); | ||
103 | da = new SqliteDataAdapter(new SqliteCommand(userSelect, conn)); | ||
104 | dua = new SqliteDataAdapter(new SqliteCommand(userAgentSelect, conn)); | ||
105 | daf = new SqliteDataAdapter(new SqliteCommand(userFriendsSelect, conn)); | ||
106 | daa = new SqliteDataAdapter(new SqliteCommand(AvatarAppearanceSelect, conn)); | ||
107 | //if (daa == null) m_log.Info("[SQLiteUserData]: daa = null"); | ||
108 | |||
109 | lock (ds) | ||
110 | { | ||
111 | ds.Tables.Add(createUsersTable()); | ||
112 | ds.Tables.Add(createUserAgentsTable()); | ||
113 | ds.Tables.Add(createUserFriendsTable()); | ||
114 | ds.Tables.Add(createAvatarAppearanceTable()); | ||
115 | |||
116 | setupUserCommands(da, conn); | ||
117 | da.Fill(ds.Tables["users"]); | ||
118 | |||
119 | setupAgentCommands(dua, conn); | ||
120 | dua.Fill(ds.Tables["useragents"]); | ||
121 | |||
122 | setupUserFriendsCommands(daf, conn); | ||
123 | daf.Fill(ds.Tables["userfriends"]); | ||
124 | |||
125 | setupAvatarAppearanceCommands(daa, conn); | ||
126 | daa.Fill(ds.Tables["avatarappearance"]); | ||
127 | } | ||
128 | |||
129 | return; | ||
130 | } | ||
131 | |||
132 | public override void Dispose () | ||
133 | { | ||
134 | if (g_conn != null) | ||
135 | { | ||
136 | g_conn.Close(); | ||
137 | g_conn = null; | ||
138 | } | ||
139 | if (ds != null) | ||
140 | { | ||
141 | ds.Dispose(); | ||
142 | ds = null; | ||
143 | } | ||
144 | if (da != null) | ||
145 | { | ||
146 | da.Dispose(); | ||
147 | da = null; | ||
148 | } | ||
149 | if (daf != null) | ||
150 | { | ||
151 | daf.Dispose(); | ||
152 | daf = null; | ||
153 | } | ||
154 | if (dua != null) | ||
155 | { | ||
156 | dua.Dispose(); | ||
157 | dua = null; | ||
158 | } | ||
159 | if (daa != null) | ||
160 | { | ||
161 | daa.Dispose(); | ||
162 | daa = null; | ||
163 | } | ||
164 | } | ||
165 | |||
166 | /// <summary> | ||
167 | /// see IUserDataPlugin, | ||
168 | /// Get user data profile by UUID | ||
169 | /// </summary> | ||
170 | /// <param name="uuid">User UUID</param> | ||
171 | /// <returns>user profile data</returns> | ||
172 | override public UserProfileData GetUserByUUID(UUID uuid) | ||
173 | { | ||
174 | lock (ds) | ||
175 | { | ||
176 | DataRow row = ds.Tables["users"].Rows.Find(uuid.ToString()); | ||
177 | if (row != null) | ||
178 | { | ||
179 | UserProfileData user = buildUserProfile(row); | ||
180 | return user; | ||
181 | } | ||
182 | else | ||
183 | { | ||
184 | return null; | ||
185 | } | ||
186 | } | ||
187 | } | ||
188 | |||
189 | /// <summary> | ||
190 | /// see IUserDataPlugin, | ||
191 | /// Get user data profile by name | ||
192 | /// </summary> | ||
193 | /// <param name="fname">first name</param> | ||
194 | /// <param name="lname">last name</param> | ||
195 | /// <returns>user profile data</returns> | ||
196 | override public UserProfileData GetUserByName(string fname, string lname) | ||
197 | { | ||
198 | string select = "surname = '" + lname + "' and username = '" + fname + "'"; | ||
199 | lock (ds) | ||
200 | { | ||
201 | DataRow[] rows = ds.Tables["users"].Select(select); | ||
202 | if (rows.Length > 0) | ||
203 | { | ||
204 | UserProfileData user = buildUserProfile(rows[0]); | ||
205 | return user; | ||
206 | } | ||
207 | else | ||
208 | { | ||
209 | return null; | ||
210 | } | ||
211 | } | ||
212 | } | ||
213 | |||
214 | #region User Friends List Data | ||
215 | |||
216 | private bool ExistsFriend(UUID owner, UUID friend) | ||
217 | { | ||
218 | string FindFriends = "select * from userfriends where (ownerID=:ownerID and friendID=:friendID) or (ownerID=:friendID and friendID=:ownerID)"; | ||
219 | using (SqliteCommand cmd = new SqliteCommand(FindFriends, g_conn)) | ||
220 | { | ||
221 | cmd.Parameters.Add(new SqliteParameter(":ownerID", owner.ToString())); | ||
222 | cmd.Parameters.Add(new SqliteParameter(":friendID", friend.ToString())); | ||
223 | try | ||
224 | { | ||
225 | using (IDataReader reader = cmd.ExecuteReader()) | ||
226 | { | ||
227 | if (reader.Read()) | ||
228 | { | ||
229 | reader.Close(); | ||
230 | return true; | ||
231 | } | ||
232 | else | ||
233 | { | ||
234 | reader.Close(); | ||
235 | return false; | ||
236 | } | ||
237 | } | ||
238 | } | ||
239 | catch (Exception ex) | ||
240 | { | ||
241 | m_log.Error("[USER DB]: Exception getting friends list for user: " + ex.ToString()); | ||
242 | return false; | ||
243 | } | ||
244 | } | ||
245 | } | ||
246 | /// <summary> | ||
247 | /// Add a new friend in the friendlist | ||
248 | /// </summary> | ||
249 | /// <param name="friendlistowner">UUID of the friendlist owner</param> | ||
250 | /// <param name="friend">UUID of the friend to add</param> | ||
251 | /// <param name="perms">permission flag</param> | ||
252 | override public void AddNewUserFriend(UUID friendlistowner, UUID friend, uint perms) | ||
253 | { | ||
254 | if (ExistsFriend(friendlistowner, friend)) | ||
255 | return; | ||
256 | |||
257 | string InsertFriends = "insert into userfriends(ownerID, friendID, friendPerms) values(:ownerID, :friendID, :perms)"; | ||
258 | using (SqliteCommand cmd = new SqliteCommand(InsertFriends, g_conn)) | ||
259 | { | ||
260 | cmd.Parameters.Add(new SqliteParameter(":ownerID", friendlistowner.ToString())); | ||
261 | cmd.Parameters.Add(new SqliteParameter(":friendID", friend.ToString())); | ||
262 | cmd.Parameters.Add(new SqliteParameter(":perms", perms)); | ||
263 | cmd.ExecuteNonQuery(); | ||
264 | } | ||
265 | using (SqliteCommand cmd = new SqliteCommand(InsertFriends, g_conn)) | ||
266 | { | ||
267 | cmd.Parameters.Add(new SqliteParameter(":ownerID", friend.ToString())); | ||
268 | cmd.Parameters.Add(new SqliteParameter(":friendID", friendlistowner.ToString())); | ||
269 | cmd.Parameters.Add(new SqliteParameter(":perms", perms)); | ||
270 | cmd.ExecuteNonQuery(); | ||
271 | } | ||
272 | } | ||
273 | |||
274 | /// <summary> | ||
275 | /// Remove a user from the friendlist | ||
276 | /// </summary> | ||
277 | /// <param name="friendlistowner">UUID of the friendlist owner</param> | ||
278 | /// <param name="friend">UUID of the friend to remove</param> | ||
279 | override public void RemoveUserFriend(UUID friendlistowner, UUID friend) | ||
280 | { | ||
281 | string DeletePerms = "delete from userfriends where (ownerID=:ownerID and friendID=:friendID) or (ownerID=:friendID and friendID=:ownerID)"; | ||
282 | using (SqliteCommand cmd = new SqliteCommand(DeletePerms, g_conn)) | ||
283 | { | ||
284 | cmd.Parameters.Add(new SqliteParameter(":ownerID", friendlistowner.ToString())); | ||
285 | cmd.Parameters.Add(new SqliteParameter(":friendID", friend.ToString())); | ||
286 | cmd.ExecuteNonQuery(); | ||
287 | } | ||
288 | } | ||
289 | |||
290 | /// <summary> | ||
291 | /// Update the friendlist permission | ||
292 | /// </summary> | ||
293 | /// <param name="friendlistowner">UUID of the friendlist owner</param> | ||
294 | /// <param name="friend">UUID of the friend to modify</param> | ||
295 | /// <param name="perms">updated permission flag</param> | ||
296 | override public void UpdateUserFriendPerms(UUID friendlistowner, UUID friend, uint perms) | ||
297 | { | ||
298 | string UpdatePerms = "update userfriends set friendPerms=:perms where ownerID=:ownerID and friendID=:friendID"; | ||
299 | using (SqliteCommand cmd = new SqliteCommand(UpdatePerms, g_conn)) | ||
300 | { | ||
301 | cmd.Parameters.Add(new SqliteParameter(":perms", perms)); | ||
302 | cmd.Parameters.Add(new SqliteParameter(":ownerID", friendlistowner.ToString())); | ||
303 | cmd.Parameters.Add(new SqliteParameter(":friendID", friend.ToString())); | ||
304 | cmd.ExecuteNonQuery(); | ||
305 | } | ||
306 | } | ||
307 | |||
308 | /// <summary> | ||
309 | /// Get (fetch?) the friendlist for a user | ||
310 | /// </summary> | ||
311 | /// <param name="friendlistowner">UUID of the friendlist owner</param> | ||
312 | /// <returns>The friendlist list</returns> | ||
313 | override public List<FriendListItem> GetUserFriendList(UUID friendlistowner) | ||
314 | { | ||
315 | List<FriendListItem> returnlist = new List<FriendListItem>(); | ||
316 | |||
317 | using (SqliteCommand cmd = new SqliteCommand(SelectFriendsByUUID, g_conn)) | ||
318 | { | ||
319 | cmd.Parameters.Add(new SqliteParameter(":ownerID", friendlistowner.ToString())); | ||
320 | |||
321 | try | ||
322 | { | ||
323 | using (IDataReader reader = cmd.ExecuteReader()) | ||
324 | { | ||
325 | while (reader.Read()) | ||
326 | { | ||
327 | FriendListItem user = new FriendListItem(); | ||
328 | user.FriendListOwner = friendlistowner; | ||
329 | user.Friend = new UUID((string)reader[0]); | ||
330 | user.FriendPerms = Convert.ToUInt32(reader[1]); | ||
331 | user.FriendListOwnerPerms = Convert.ToUInt32(reader[2]); | ||
332 | returnlist.Add(user); | ||
333 | } | ||
334 | reader.Close(); | ||
335 | } | ||
336 | } | ||
337 | catch (Exception ex) | ||
338 | { | ||
339 | m_log.Error("[USER DB]: Exception getting friends list for user: " + ex.ToString()); | ||
340 | } | ||
341 | } | ||
342 | |||
343 | return returnlist; | ||
344 | } | ||
345 | |||
346 | override public Dictionary<UUID, FriendRegionInfo> GetFriendRegionInfos (List<UUID> uuids) | ||
347 | { | ||
348 | Dictionary<UUID, FriendRegionInfo> infos = new Dictionary<UUID,FriendRegionInfo>(); | ||
349 | |||
350 | DataTable agents = ds.Tables["useragents"]; | ||
351 | foreach (UUID uuid in uuids) | ||
352 | { | ||
353 | lock (ds) | ||
354 | { | ||
355 | DataRow row = agents.Rows.Find(uuid.ToString()); | ||
356 | if (row == null) infos[uuid] = null; | ||
357 | else | ||
358 | { | ||
359 | FriendRegionInfo fri = new FriendRegionInfo(); | ||
360 | fri.isOnline = (bool)row["agentOnline"]; | ||
361 | fri.regionHandle = Convert.ToUInt64(row["currentHandle"]); | ||
362 | infos[uuid] = fri; | ||
363 | } | ||
364 | } | ||
365 | } | ||
366 | return infos; | ||
367 | } | ||
368 | |||
369 | #endregion | ||
370 | |||
371 | /// <summary> | ||
372 | /// | ||
373 | /// </summary> | ||
374 | /// <param name="queryID"></param> | ||
375 | /// <param name="query"></param> | ||
376 | /// <returns></returns> | ||
377 | override public List<AvatarPickerAvatar> GeneratePickerResults(UUID queryID, string query) | ||
378 | { | ||
379 | List<AvatarPickerAvatar> returnlist = new List<AvatarPickerAvatar>(); | ||
380 | string[] querysplit; | ||
381 | querysplit = query.Split(' '); | ||
382 | if (querysplit.Length == 2) | ||
383 | { | ||
384 | using (SqliteCommand cmd = new SqliteCommand(AvatarPickerAndSQL, g_conn)) | ||
385 | { | ||
386 | cmd.Parameters.Add(new SqliteParameter(":username", querysplit[0] + "%")); | ||
387 | cmd.Parameters.Add(new SqliteParameter(":surname", querysplit[1] + "%")); | ||
388 | |||
389 | using (IDataReader reader = cmd.ExecuteReader()) | ||
390 | { | ||
391 | while (reader.Read()) | ||
392 | { | ||
393 | AvatarPickerAvatar user = new AvatarPickerAvatar(); | ||
394 | user.AvatarID = new UUID((string) reader["UUID"]); | ||
395 | user.firstName = (string) reader["username"]; | ||
396 | user.lastName = (string) reader["surname"]; | ||
397 | returnlist.Add(user); | ||
398 | } | ||
399 | reader.Close(); | ||
400 | } | ||
401 | } | ||
402 | } | ||
403 | else if (querysplit.Length == 1) | ||
404 | { | ||
405 | using (SqliteCommand cmd = new SqliteCommand(AvatarPickerOrSQL, g_conn)) | ||
406 | { | ||
407 | cmd.Parameters.Add(new SqliteParameter(":username", querysplit[0] + "%")); | ||
408 | cmd.Parameters.Add(new SqliteParameter(":surname", querysplit[0] + "%")); | ||
409 | |||
410 | using (IDataReader reader = cmd.ExecuteReader()) | ||
411 | { | ||
412 | while (reader.Read()) | ||
413 | { | ||
414 | AvatarPickerAvatar user = new AvatarPickerAvatar(); | ||
415 | user.AvatarID = new UUID((string) reader["UUID"]); | ||
416 | user.firstName = (string) reader["username"]; | ||
417 | user.lastName = (string) reader["surname"]; | ||
418 | returnlist.Add(user); | ||
419 | } | ||
420 | reader.Close(); | ||
421 | } | ||
422 | } | ||
423 | } | ||
424 | return returnlist; | ||
425 | } | ||
426 | |||
427 | /// <summary> | ||
428 | /// Returns a user by UUID direct | ||
429 | /// </summary> | ||
430 | /// <param name="uuid">The user's account ID</param> | ||
431 | /// <returns>A matching user profile</returns> | ||
432 | override public UserAgentData GetAgentByUUID(UUID uuid) | ||
433 | { | ||
434 | lock (ds) | ||
435 | { | ||
436 | DataRow row = ds.Tables["useragents"].Rows.Find(uuid.ToString()); | ||
437 | if (row != null) | ||
438 | { | ||
439 | return buildUserAgent(row); | ||
440 | } | ||
441 | else | ||
442 | { | ||
443 | return null; | ||
444 | } | ||
445 | } | ||
446 | } | ||
447 | |||
448 | /// <summary> | ||
449 | /// Returns a session by account name | ||
450 | /// </summary> | ||
451 | /// <param name="name">The account name</param> | ||
452 | /// <returns>The user's session agent</returns> | ||
453 | override public UserAgentData GetAgentByName(string name) | ||
454 | { | ||
455 | return GetAgentByName(name.Split(' ')[0], name.Split(' ')[1]); | ||
456 | } | ||
457 | |||
458 | /// <summary> | ||
459 | /// Returns a session by account name | ||
460 | /// </summary> | ||
461 | /// <param name="fname">The first part of the user's account name</param> | ||
462 | /// <param name="lname">The second part of the user's account name</param> | ||
463 | /// <returns>A user agent</returns> | ||
464 | override public UserAgentData GetAgentByName(string fname, string lname) | ||
465 | { | ||
466 | UserAgentData agent = null; | ||
467 | |||
468 | UserProfileData profile = GetUserByName(fname, lname); | ||
469 | if (profile != null) | ||
470 | { | ||
471 | agent = GetAgentByUUID(profile.ID); | ||
472 | } | ||
473 | return agent; | ||
474 | } | ||
475 | |||
476 | /// <summary> | ||
477 | /// DEPRECATED? Store the weblogin key | ||
478 | /// </summary> | ||
479 | /// <param name="AgentID">UUID of the user</param> | ||
480 | /// <param name="WebLoginKey">UUID of the weblogin</param> | ||
481 | override public void StoreWebLoginKey(UUID AgentID, UUID WebLoginKey) | ||
482 | { | ||
483 | DataTable users = ds.Tables["users"]; | ||
484 | lock (ds) | ||
485 | { | ||
486 | DataRow row = users.Rows.Find(AgentID.ToString()); | ||
487 | if (row == null) | ||
488 | { | ||
489 | m_log.Warn("[USER DB]: Unable to store new web login key for non-existant user"); | ||
490 | } | ||
491 | else | ||
492 | { | ||
493 | UserProfileData user = GetUserByUUID(AgentID); | ||
494 | user.WebLoginKey = WebLoginKey; | ||
495 | fillUserRow(row, user); | ||
496 | da.Update(ds, "users"); | ||
497 | } | ||
498 | } | ||
499 | } | ||
500 | |||
501 | private bool ExistsFirstLastName(String fname, String lname) | ||
502 | { | ||
503 | string FindUser = "select * from users where (username=:username and surname=:surname)"; | ||
504 | using (SqliteCommand cmd = new SqliteCommand(FindUser, g_conn)) | ||
505 | { | ||
506 | cmd.Parameters.Add(new SqliteParameter(":username", fname)); | ||
507 | cmd.Parameters.Add(new SqliteParameter(":surname", lname)); | ||
508 | try | ||
509 | { | ||
510 | using (IDataReader reader = cmd.ExecuteReader()) | ||
511 | { | ||
512 | if (reader.Read()) | ||
513 | { | ||
514 | reader.Close(); | ||
515 | return true; | ||
516 | } | ||
517 | else | ||
518 | { | ||
519 | reader.Close(); | ||
520 | return false; | ||
521 | } | ||
522 | } | ||
523 | } | ||
524 | catch (Exception ex) | ||
525 | { | ||
526 | m_log.Error("[USER DB]: Exception searching for user's first and last name: " + ex.ToString()); | ||
527 | return false; | ||
528 | } | ||
529 | } | ||
530 | } | ||
531 | |||
532 | /// <summary> | ||
533 | /// Creates a new user profile | ||
534 | /// </summary> | ||
535 | /// <param name="user">The profile to add to the database</param> | ||
536 | override public void AddNewUserProfile(UserProfileData user) | ||
537 | { | ||
538 | DataTable users = ds.Tables["users"]; | ||
539 | UUID zero = UUID.Zero; | ||
540 | if (ExistsFirstLastName(user.FirstName, user.SurName) || user.ID == zero) | ||
541 | return; | ||
542 | |||
543 | lock (ds) | ||
544 | { | ||
545 | DataRow row = users.Rows.Find(user.ID.ToString()); | ||
546 | if (row == null) | ||
547 | { | ||
548 | row = users.NewRow(); | ||
549 | fillUserRow(row, user); | ||
550 | users.Rows.Add(row); | ||
551 | |||
552 | m_log.Debug("[USER DB]: Syncing user database: " + ds.Tables["users"].Rows.Count + " users stored"); | ||
553 | |||
554 | // save changes off to disk | ||
555 | da.Update(ds, "users"); | ||
556 | } | ||
557 | else | ||
558 | { | ||
559 | m_log.WarnFormat("[USER DB]: Ignoring add since user with id {0} already exists", user.ID); | ||
560 | } | ||
561 | } | ||
562 | } | ||
563 | |||
564 | /// <summary> | ||
565 | /// Creates a new user profile | ||
566 | /// </summary> | ||
567 | /// <param name="user">The profile to add to the database</param> | ||
568 | /// <returns>True on success, false on error</returns> | ||
569 | override public bool UpdateUserProfile(UserProfileData user) | ||
570 | { | ||
571 | DataTable users = ds.Tables["users"]; | ||
572 | lock (ds) | ||
573 | { | ||
574 | DataRow row = users.Rows.Find(user.ID.ToString()); | ||
575 | if (row == null) | ||
576 | { | ||
577 | return false; | ||
578 | } | ||
579 | else | ||
580 | { | ||
581 | fillUserRow(row, user); | ||
582 | da.Update(ds, "users"); | ||
583 | } | ||
584 | } | ||
585 | |||
586 | //AddNewUserProfile(user); | ||
587 | return true; | ||
588 | } | ||
589 | |||
590 | /// <summary> | ||
591 | /// Creates a new user agent | ||
592 | /// </summary> | ||
593 | /// <param name="agent">The agent to add to the database</param> | ||
594 | override public void AddNewUserAgent(UserAgentData agent) | ||
595 | { | ||
596 | UUID zero = UUID.Zero; | ||
597 | if (agent.SessionID == zero || agent.ProfileID == zero) | ||
598 | return; | ||
599 | |||
600 | DataTable agents = ds.Tables["useragents"]; | ||
601 | lock (ds) | ||
602 | { | ||
603 | DataRow row = agents.Rows.Find(agent.ProfileID.ToString()); | ||
604 | if (row == null) | ||
605 | { | ||
606 | row = agents.NewRow(); | ||
607 | fillUserAgentRow(row, agent); | ||
608 | agents.Rows.Add(row); | ||
609 | } | ||
610 | else | ||
611 | { | ||
612 | fillUserAgentRow(row, agent); | ||
613 | |||
614 | } | ||
615 | m_log.Info("[USER DB]: Syncing useragent database: " + ds.Tables["useragents"].Rows.Count + " agents stored"); | ||
616 | // save changes off to disk | ||
617 | dua.Update(ds, "useragents"); | ||
618 | } | ||
619 | } | ||
620 | |||
621 | /// <summary> | ||
622 | /// Transfers money between two user accounts | ||
623 | /// </summary> | ||
624 | /// <param name="from">Starting account</param> | ||
625 | /// <param name="to">End account</param> | ||
626 | /// <param name="amount">The amount to move</param> | ||
627 | /// <returns>Success?</returns> | ||
628 | override public bool MoneyTransferRequest(UUID from, UUID to, uint amount) | ||
629 | { | ||
630 | return false; // for consistency with the MySQL impl | ||
631 | } | ||
632 | |||
633 | /// <summary> | ||
634 | /// Transfers inventory between two accounts | ||
635 | /// </summary> | ||
636 | /// <remarks>Move to inventory server</remarks> | ||
637 | /// <param name="from">Senders account</param> | ||
638 | /// <param name="to">Receivers account</param> | ||
639 | /// <param name="item">Inventory item</param> | ||
640 | /// <returns>Success?</returns> | ||
641 | override public bool InventoryTransferRequest(UUID from, UUID to, UUID item) | ||
642 | { | ||
643 | return false; //for consistency with the MySQL impl | ||
644 | } | ||
645 | |||
646 | |||
647 | /// <summary> | ||
648 | /// Appearance. | ||
649 | /// TODO: stubs for now to do in memory appearance. | ||
650 | /// </summary> | ||
651 | /// <param name="user">The user UUID</param> | ||
652 | /// <returns>Avatar Appearence</returns> | ||
653 | override public AvatarAppearance GetUserAppearance(UUID user) | ||
654 | { | ||
655 | m_log.Info("[APPEARANCE] GetUserAppearance " + user.ToString()); | ||
656 | |||
657 | AvatarAppearance aa = new AvatarAppearance(user); | ||
658 | //try { | ||
659 | aa.Owner = user; | ||
660 | |||
661 | DataTable aap = ds.Tables["avatarappearance"]; | ||
662 | lock (ds) | ||
663 | { | ||
664 | DataRow row = aap.Rows.Find(Util.ToRawUuidString(user)); | ||
665 | if (row == null) | ||
666 | { | ||
667 | m_log.Info("[APPEARANCE] Could not find appearance for " + user.ToString()); | ||
668 | |||
669 | //m_log.Debug("[USER DB]: Creating avatarappearance For: " + user.ToString()); | ||
670 | |||
671 | //row = aap.NewRow(); | ||
672 | //fillAvatarAppearanceRow(row, user, appearance); | ||
673 | //aap.Rows.Add(row); | ||
674 | // m_log.Debug("[USER DB]: Syncing user database: " + ds.Tables["users"].Rows.Count + " users stored"); | ||
675 | // save changes off to disk | ||
676 | //daa.Update(ds, "avatarappearance"); | ||
677 | } | ||
678 | else | ||
679 | { | ||
680 | m_log.InfoFormat("[APPEARANCE] appearance found for {0}", user.ToString()); | ||
681 | |||
682 | aa.BodyAsset = new UUID((String)row["BodyAsset"]); | ||
683 | aa.BodyItem = new UUID((String)row["BodyItem"]); | ||
684 | aa.SkinItem = new UUID((String)row["SkinItem"]); | ||
685 | aa.SkinAsset = new UUID((String)row["SkinAsset"]); | ||
686 | aa.HairItem = new UUID((String)row["HairItem"]); | ||
687 | aa.HairAsset = new UUID((String)row["HairAsset"]); | ||
688 | aa.EyesItem = new UUID((String)row["EyesItem"]); | ||
689 | aa.EyesAsset = new UUID((String)row["EyesAsset"]); | ||
690 | aa.ShirtItem = new UUID((String)row["ShirtItem"]); | ||
691 | aa.ShirtAsset = new UUID((String)row["ShirtAsset"]); | ||
692 | aa.PantsItem = new UUID((String)row["PantsItem"]); | ||
693 | aa.PantsAsset = new UUID((String)row["PantsAsset"]); | ||
694 | aa.ShoesItem = new UUID((String)row["ShoesItem"]); | ||
695 | aa.ShoesAsset = new UUID((String)row["ShoesAsset"]); | ||
696 | aa.SocksItem = new UUID((String)row["SocksItem"]); | ||
697 | aa.SocksAsset = new UUID((String)row["SocksAsset"]); | ||
698 | aa.JacketItem = new UUID((String)row["JacketItem"]); | ||
699 | aa.JacketAsset = new UUID((String)row["JacketAsset"]); | ||
700 | aa.GlovesItem = new UUID((String)row["GlovesItem"]); | ||
701 | aa.GlovesAsset = new UUID((String)row["GlovesAsset"]); | ||
702 | aa.UnderShirtItem = new UUID((String)row["UnderShirtItem"]); | ||
703 | aa.UnderShirtAsset = new UUID((String)row["UnderShirtAsset"]); | ||
704 | aa.UnderPantsItem = new UUID((String)row["UnderPantsItem"]); | ||
705 | aa.UnderPantsAsset = new UUID((String)row["UnderPantsAsset"]); | ||
706 | aa.SkirtItem = new UUID((String)row["SkirtItem"]); | ||
707 | aa.SkirtAsset = new UUID((String)row["SkirtAsset"]); | ||
708 | |||
709 | // Ewe Loon | ||
710 | // Used Base64String because for some reason it wont accept using Byte[] (which works in Region date) | ||
711 | |||
712 | String str = (String)row["Texture"]; | ||
713 | byte[] texture = Convert.FromBase64String(str); | ||
714 | aa.Texture = new Primitive.TextureEntry(texture, 0, texture.Length); | ||
715 | |||
716 | str = (String)row["VisualParams"]; | ||
717 | byte[] VisualParams = Convert.FromBase64String(str); | ||
718 | aa.VisualParams = VisualParams; | ||
719 | |||
720 | aa.Serial = Convert.ToInt32(row["Serial"]); | ||
721 | aa.AvatarHeight = Convert.ToSingle(row["AvatarHeight"]); | ||
722 | m_log.InfoFormat("[APPEARANCE] appearance set for {0}", user.ToString()); | ||
723 | } | ||
724 | } | ||
725 | |||
726 | // m_log.Info("[APPEARANCE] Found appearance for " + user.ToString() + aa.ToString()); | ||
727 | // } catch (KeyNotFoundException) { | ||
728 | // m_log.InfoFormat("[APPEARANCE] No appearance found for {0}", user.ToString()); | ||
729 | // } | ||
730 | return aa; | ||
731 | } | ||
732 | |||
733 | /// <summary> | ||
734 | /// Update a user appearence | ||
735 | /// </summary> | ||
736 | /// <param name="user">the user UUID</param> | ||
737 | /// <param name="appearance">appearence</param> | ||
738 | override public void UpdateUserAppearance(UUID user, AvatarAppearance appearance) | ||
739 | { | ||
740 | appearance.Owner = user; | ||
741 | DataTable aap = ds.Tables["avatarappearance"]; | ||
742 | lock (ds) | ||
743 | { | ||
744 | DataRow row = aap.Rows.Find(Util.ToRawUuidString(user)); | ||
745 | if (row == null) | ||
746 | { | ||
747 | m_log.Debug("[USER DB]: Creating UserAppearance For: " + user.ToString()); | ||
748 | |||
749 | row = aap.NewRow(); | ||
750 | fillAvatarAppearanceRow(row, user, appearance); | ||
751 | aap.Rows.Add(row); | ||
752 | // m_log.Debug("[USER DB]: Syncing user database: " + ds.Tables["users"].Rows.Count + " users stored"); | ||
753 | // save changes off to disk | ||
754 | daa.Update(ds, "avatarappearance"); | ||
755 | } | ||
756 | else | ||
757 | { | ||
758 | m_log.Debug("[USER DB]: Updating UserAppearance For: " + user.ToString()); | ||
759 | fillAvatarAppearanceRow(row, user, appearance); | ||
760 | daa.Update(ds, "avatarappearance"); | ||
761 | } | ||
762 | } | ||
763 | } | ||
764 | |||
765 | /// <summary> | ||
766 | /// Returns the name of the storage provider | ||
767 | /// </summary> | ||
768 | /// <returns>Storage provider name</returns> | ||
769 | override public string Name | ||
770 | { | ||
771 | get {return "Sqlite Userdata";} | ||
772 | } | ||
773 | |||
774 | /// <summary> | ||
775 | /// Returns the version of the storage provider | ||
776 | /// </summary> | ||
777 | /// <returns>Storage provider version</returns> | ||
778 | override public string Version | ||
779 | { | ||
780 | get {return "0.1";} | ||
781 | } | ||
782 | |||
783 | /*********************************************************************** | ||
784 | * | ||
785 | * DataTable creation | ||
786 | * | ||
787 | **********************************************************************/ | ||
788 | /*********************************************************************** | ||
789 | * | ||
790 | * Database Definition Functions | ||
791 | * | ||
792 | * This should be db agnostic as we define them in ADO.NET terms | ||
793 | * | ||
794 | **********************************************************************/ | ||
795 | |||
796 | /// <summary> | ||
797 | /// Create the "users" table | ||
798 | /// </summary> | ||
799 | /// <returns>DataTable</returns> | ||
800 | private static DataTable createUsersTable() | ||
801 | { | ||
802 | DataTable users = new DataTable("users"); | ||
803 | |||
804 | SQLiteUtil.createCol(users, "UUID", typeof (String)); | ||
805 | SQLiteUtil.createCol(users, "username", typeof (String)); | ||
806 | SQLiteUtil.createCol(users, "surname", typeof (String)); | ||
807 | SQLiteUtil.createCol(users, "email", typeof (String)); | ||
808 | SQLiteUtil.createCol(users, "passwordHash", typeof (String)); | ||
809 | SQLiteUtil.createCol(users, "passwordSalt", typeof (String)); | ||
810 | |||
811 | SQLiteUtil.createCol(users, "homeRegionX", typeof (Int32)); | ||
812 | SQLiteUtil.createCol(users, "homeRegionY", typeof (Int32)); | ||
813 | SQLiteUtil.createCol(users, "homeRegionID", typeof (String)); | ||
814 | SQLiteUtil.createCol(users, "homeLocationX", typeof (Double)); | ||
815 | SQLiteUtil.createCol(users, "homeLocationY", typeof (Double)); | ||
816 | SQLiteUtil.createCol(users, "homeLocationZ", typeof (Double)); | ||
817 | SQLiteUtil.createCol(users, "homeLookAtX", typeof (Double)); | ||
818 | SQLiteUtil.createCol(users, "homeLookAtY", typeof (Double)); | ||
819 | SQLiteUtil.createCol(users, "homeLookAtZ", typeof (Double)); | ||
820 | SQLiteUtil.createCol(users, "created", typeof (Int32)); | ||
821 | SQLiteUtil.createCol(users, "lastLogin", typeof (Int32)); | ||
822 | |||
823 | //TODO: Please delete this column. It's now a brick | ||
824 | SQLiteUtil.createCol(users, "rootInventoryFolderID", typeof (String)); | ||
825 | |||
826 | SQLiteUtil.createCol(users, "userInventoryURI", typeof (String)); | ||
827 | SQLiteUtil.createCol(users, "userAssetURI", typeof (String)); | ||
828 | SQLiteUtil.createCol(users, "profileCanDoMask", typeof (Int32)); | ||
829 | SQLiteUtil.createCol(users, "profileWantDoMask", typeof (Int32)); | ||
830 | SQLiteUtil.createCol(users, "profileAboutText", typeof (String)); | ||
831 | SQLiteUtil.createCol(users, "profileFirstText", typeof (String)); | ||
832 | SQLiteUtil.createCol(users, "profileImage", typeof (String)); | ||
833 | SQLiteUtil.createCol(users, "profileFirstImage", typeof (String)); | ||
834 | SQLiteUtil.createCol(users, "webLoginKey", typeof(String)); | ||
835 | SQLiteUtil.createCol(users, "userFlags", typeof (Int32)); | ||
836 | SQLiteUtil.createCol(users, "godLevel", typeof (Int32)); | ||
837 | SQLiteUtil.createCol(users, "customType", typeof (String)); | ||
838 | SQLiteUtil.createCol(users, "partner", typeof (String)); | ||
839 | // Add in contraints | ||
840 | users.PrimaryKey = new DataColumn[] {users.Columns["UUID"]}; | ||
841 | return users; | ||
842 | } | ||
843 | |||
844 | /// <summary> | ||
845 | /// Create the "useragents" table | ||
846 | /// </summary> | ||
847 | /// <returns>Data Table</returns> | ||
848 | private static DataTable createUserAgentsTable() | ||
849 | { | ||
850 | DataTable ua = new DataTable("useragents"); | ||
851 | // this is the UUID of the user | ||
852 | SQLiteUtil.createCol(ua, "UUID", typeof (String)); | ||
853 | SQLiteUtil.createCol(ua, "agentIP", typeof (String)); | ||
854 | SQLiteUtil.createCol(ua, "agentPort", typeof (Int32)); | ||
855 | SQLiteUtil.createCol(ua, "agentOnline", typeof (Boolean)); | ||
856 | SQLiteUtil.createCol(ua, "sessionID", typeof (String)); | ||
857 | SQLiteUtil.createCol(ua, "secureSessionID", typeof (String)); | ||
858 | SQLiteUtil.createCol(ua, "regionID", typeof (String)); | ||
859 | SQLiteUtil.createCol(ua, "loginTime", typeof (Int32)); | ||
860 | SQLiteUtil.createCol(ua, "logoutTime", typeof (Int32)); | ||
861 | SQLiteUtil.createCol(ua, "currentRegion", typeof (String)); | ||
862 | SQLiteUtil.createCol(ua, "currentHandle", typeof (String)); | ||
863 | // vectors | ||
864 | SQLiteUtil.createCol(ua, "currentPosX", typeof (Double)); | ||
865 | SQLiteUtil.createCol(ua, "currentPosY", typeof (Double)); | ||
866 | SQLiteUtil.createCol(ua, "currentPosZ", typeof (Double)); | ||
867 | // constraints | ||
868 | ua.PrimaryKey = new DataColumn[] {ua.Columns["UUID"]}; | ||
869 | |||
870 | return ua; | ||
871 | } | ||
872 | |||
873 | /// <summary> | ||
874 | /// Create the "userfriends" table | ||
875 | /// </summary> | ||
876 | /// <returns>Data Table</returns> | ||
877 | private static DataTable createUserFriendsTable() | ||
878 | { | ||
879 | DataTable ua = new DataTable("userfriends"); | ||
880 | // table contains user <----> user relationship with perms | ||
881 | SQLiteUtil.createCol(ua, "ownerID", typeof(String)); | ||
882 | SQLiteUtil.createCol(ua, "friendID", typeof(String)); | ||
883 | SQLiteUtil.createCol(ua, "friendPerms", typeof(Int32)); | ||
884 | SQLiteUtil.createCol(ua, "ownerPerms", typeof(Int32)); | ||
885 | SQLiteUtil.createCol(ua, "datetimestamp", typeof(Int32)); | ||
886 | |||
887 | return ua; | ||
888 | } | ||
889 | |||
890 | /// <summary> | ||
891 | /// Create the "avatarappearance" table | ||
892 | /// </summary> | ||
893 | /// <returns>Data Table</returns> | ||
894 | private static DataTable createAvatarAppearanceTable() | ||
895 | { | ||
896 | DataTable aa = new DataTable("avatarappearance"); | ||
897 | // table contains user appearance items | ||
898 | |||
899 | SQLiteUtil.createCol(aa, "Owner", typeof(String)); | ||
900 | SQLiteUtil.createCol(aa, "BodyItem", typeof(String)); | ||
901 | SQLiteUtil.createCol(aa, "BodyAsset", typeof(String)); | ||
902 | SQLiteUtil.createCol(aa, "SkinItem", typeof(String)); | ||
903 | SQLiteUtil.createCol(aa, "SkinAsset", typeof(String)); | ||
904 | SQLiteUtil.createCol(aa, "HairItem", typeof(String)); | ||
905 | SQLiteUtil.createCol(aa, "HairAsset", typeof(String)); | ||
906 | SQLiteUtil.createCol(aa, "EyesItem", typeof(String)); | ||
907 | SQLiteUtil.createCol(aa, "EyesAsset", typeof(String)); | ||
908 | SQLiteUtil.createCol(aa, "ShirtItem", typeof(String)); | ||
909 | SQLiteUtil.createCol(aa, "ShirtAsset", typeof(String)); | ||
910 | SQLiteUtil.createCol(aa, "PantsItem", typeof(String)); | ||
911 | SQLiteUtil.createCol(aa, "PantsAsset", typeof(String)); | ||
912 | SQLiteUtil.createCol(aa, "ShoesItem", typeof(String)); | ||
913 | SQLiteUtil.createCol(aa, "ShoesAsset", typeof(String)); | ||
914 | SQLiteUtil.createCol(aa, "SocksItem", typeof(String)); | ||
915 | SQLiteUtil.createCol(aa, "SocksAsset", typeof(String)); | ||
916 | SQLiteUtil.createCol(aa, "JacketItem", typeof(String)); | ||
917 | SQLiteUtil.createCol(aa, "JacketAsset", typeof(String)); | ||
918 | SQLiteUtil.createCol(aa, "GlovesItem", typeof(String)); | ||
919 | SQLiteUtil.createCol(aa, "GlovesAsset", typeof(String)); | ||
920 | SQLiteUtil.createCol(aa, "UnderShirtItem", typeof(String)); | ||
921 | SQLiteUtil.createCol(aa, "UnderShirtAsset", typeof(String)); | ||
922 | SQLiteUtil.createCol(aa, "UnderPantsItem", typeof(String)); | ||
923 | SQLiteUtil.createCol(aa, "UnderPantsAsset", typeof(String)); | ||
924 | SQLiteUtil.createCol(aa, "SkirtItem", typeof(String)); | ||
925 | SQLiteUtil.createCol(aa, "SkirtAsset", typeof(String)); | ||
926 | |||
927 | // Used Base64String because for some reason it wont accept using Byte[] (which works in Region date) | ||
928 | SQLiteUtil.createCol(aa, "Texture", typeof (String)); | ||
929 | SQLiteUtil.createCol(aa, "VisualParams", typeof (String)); | ||
930 | |||
931 | SQLiteUtil.createCol(aa, "Serial", typeof(Int32)); | ||
932 | SQLiteUtil.createCol(aa, "AvatarHeight", typeof(Double)); | ||
933 | |||
934 | aa.PrimaryKey = new DataColumn[] { aa.Columns["Owner"] }; | ||
935 | |||
936 | return aa; | ||
937 | } | ||
938 | |||
939 | /*********************************************************************** | ||
940 | * | ||
941 | * Convert between ADO.NET <=> OpenSim Objects | ||
942 | * | ||
943 | * These should be database independant | ||
944 | * | ||
945 | **********************************************************************/ | ||
946 | |||
947 | /// <summary> | ||
948 | /// TODO: this doesn't work yet because something more | ||
949 | /// interesting has to be done to actually get these values | ||
950 | /// back out. Not enough time to figure it out yet. | ||
951 | /// </summary> | ||
952 | /// <param name="row"></param> | ||
953 | /// <returns></returns> | ||
954 | private static UserProfileData buildUserProfile(DataRow row) | ||
955 | { | ||
956 | UserProfileData user = new UserProfileData(); | ||
957 | UUID tmp; | ||
958 | UUID.TryParse((String)row["UUID"], out tmp); | ||
959 | user.ID = tmp; | ||
960 | user.FirstName = (String) row["username"]; | ||
961 | user.SurName = (String) row["surname"]; | ||
962 | user.Email = (row.IsNull("email")) ? "" : (String) row["email"]; | ||
963 | |||
964 | user.PasswordHash = (String) row["passwordHash"]; | ||
965 | user.PasswordSalt = (String) row["passwordSalt"]; | ||
966 | |||
967 | user.HomeRegionX = Convert.ToUInt32(row["homeRegionX"]); | ||
968 | user.HomeRegionY = Convert.ToUInt32(row["homeRegionY"]); | ||
969 | user.HomeLocation = new Vector3( | ||
970 | Convert.ToSingle(row["homeLocationX"]), | ||
971 | Convert.ToSingle(row["homeLocationY"]), | ||
972 | Convert.ToSingle(row["homeLocationZ"]) | ||
973 | ); | ||
974 | user.HomeLookAt = new Vector3( | ||
975 | Convert.ToSingle(row["homeLookAtX"]), | ||
976 | Convert.ToSingle(row["homeLookAtY"]), | ||
977 | Convert.ToSingle(row["homeLookAtZ"]) | ||
978 | ); | ||
979 | |||
980 | UUID regionID = UUID.Zero; | ||
981 | UUID.TryParse(row["homeRegionID"].ToString(), out regionID); // it's ok if it doesn't work; just use UUID.Zero | ||
982 | user.HomeRegionID = regionID; | ||
983 | |||
984 | user.Created = Convert.ToInt32(row["created"]); | ||
985 | user.LastLogin = Convert.ToInt32(row["lastLogin"]); | ||
986 | user.UserInventoryURI = (String) row["userInventoryURI"]; | ||
987 | user.UserAssetURI = (String) row["userAssetURI"]; | ||
988 | user.CanDoMask = Convert.ToUInt32(row["profileCanDoMask"]); | ||
989 | user.WantDoMask = Convert.ToUInt32(row["profileWantDoMask"]); | ||
990 | user.AboutText = (String) row["profileAboutText"]; | ||
991 | user.FirstLifeAboutText = (String) row["profileFirstText"]; | ||
992 | UUID.TryParse((String)row["profileImage"], out tmp); | ||
993 | user.Image = tmp; | ||
994 | UUID.TryParse((String)row["profileFirstImage"], out tmp); | ||
995 | user.FirstLifeImage = tmp; | ||
996 | user.WebLoginKey = new UUID((String) row["webLoginKey"]); | ||
997 | user.UserFlags = Convert.ToInt32(row["userFlags"]); | ||
998 | user.GodLevel = Convert.ToInt32(row["godLevel"]); | ||
999 | user.CustomType = row["customType"].ToString(); | ||
1000 | user.Partner = new UUID((String) row["partner"]); | ||
1001 | |||
1002 | return user; | ||
1003 | } | ||
1004 | |||
1005 | /// <summary> | ||
1006 | /// Persist user profile data | ||
1007 | /// </summary> | ||
1008 | /// <param name="row"></param> | ||
1009 | /// <param name="user"></param> | ||
1010 | private void fillUserRow(DataRow row, UserProfileData user) | ||
1011 | { | ||
1012 | row["UUID"] = user.ID.ToString(); | ||
1013 | row["username"] = user.FirstName; | ||
1014 | row["surname"] = user.SurName; | ||
1015 | row["email"] = user.Email; | ||
1016 | row["passwordHash"] = user.PasswordHash; | ||
1017 | row["passwordSalt"] = user.PasswordSalt; | ||
1018 | |||
1019 | row["homeRegionX"] = user.HomeRegionX; | ||
1020 | row["homeRegionY"] = user.HomeRegionY; | ||
1021 | row["homeRegionID"] = user.HomeRegionID.ToString(); | ||
1022 | row["homeLocationX"] = user.HomeLocation.X; | ||
1023 | row["homeLocationY"] = user.HomeLocation.Y; | ||
1024 | row["homeLocationZ"] = user.HomeLocation.Z; | ||
1025 | row["homeLookAtX"] = user.HomeLookAt.X; | ||
1026 | row["homeLookAtY"] = user.HomeLookAt.Y; | ||
1027 | row["homeLookAtZ"] = user.HomeLookAt.Z; | ||
1028 | |||
1029 | row["created"] = user.Created; | ||
1030 | row["lastLogin"] = user.LastLogin; | ||
1031 | //TODO: Get rid of rootInventoryFolderID in a safe way. | ||
1032 | row["rootInventoryFolderID"] = UUID.Zero.ToString(); | ||
1033 | row["userInventoryURI"] = user.UserInventoryURI; | ||
1034 | row["userAssetURI"] = user.UserAssetURI; | ||
1035 | row["profileCanDoMask"] = user.CanDoMask; | ||
1036 | row["profileWantDoMask"] = user.WantDoMask; | ||
1037 | row["profileAboutText"] = user.AboutText; | ||
1038 | row["profileFirstText"] = user.FirstLifeAboutText; | ||
1039 | row["profileImage"] = user.Image.ToString(); | ||
1040 | row["profileFirstImage"] = user.FirstLifeImage.ToString(); | ||
1041 | row["webLoginKey"] = user.WebLoginKey.ToString(); | ||
1042 | row["userFlags"] = user.UserFlags; | ||
1043 | row["godLevel"] = user.GodLevel; | ||
1044 | row["customType"] = user.CustomType == null ? "" : user.CustomType; | ||
1045 | row["partner"] = user.Partner.ToString(); | ||
1046 | |||
1047 | // ADO.NET doesn't handle NULL very well | ||
1048 | foreach (DataColumn col in ds.Tables["users"].Columns) | ||
1049 | { | ||
1050 | if (row[col] == null) | ||
1051 | { | ||
1052 | row[col] = String.Empty; | ||
1053 | } | ||
1054 | } | ||
1055 | } | ||
1056 | |||
1057 | /// <summary> | ||
1058 | /// | ||
1059 | /// </summary> | ||
1060 | /// <param name="row"></param> | ||
1061 | /// <param name="user"></param> | ||
1062 | private void fillAvatarAppearanceRow(DataRow row, UUID user, AvatarAppearance appearance) | ||
1063 | { | ||
1064 | row["Owner"] = Util.ToRawUuidString(user); | ||
1065 | row["BodyItem"] = appearance.BodyItem.ToString(); | ||
1066 | row["BodyAsset"] = appearance.BodyAsset.ToString(); | ||
1067 | row["SkinItem"] = appearance.SkinItem.ToString(); | ||
1068 | row["SkinAsset"] = appearance.SkinAsset.ToString(); | ||
1069 | row["HairItem"] = appearance.HairItem.ToString(); | ||
1070 | row["HairAsset"] = appearance.HairAsset.ToString(); | ||
1071 | row["EyesItem"] = appearance.EyesItem.ToString(); | ||
1072 | row["EyesAsset"] = appearance.EyesAsset.ToString(); | ||
1073 | row["ShirtItem"] = appearance.ShirtItem.ToString(); | ||
1074 | row["ShirtAsset"] = appearance.ShirtAsset.ToString(); | ||
1075 | row["PantsItem"] = appearance.PantsItem.ToString(); | ||
1076 | row["PantsAsset"] = appearance.PantsAsset.ToString(); | ||
1077 | row["ShoesItem"] = appearance.ShoesItem.ToString(); | ||
1078 | row["ShoesAsset"] = appearance.ShoesAsset.ToString(); | ||
1079 | row["SocksItem"] = appearance.SocksItem.ToString(); | ||
1080 | row["SocksAsset"] = appearance.SocksAsset.ToString(); | ||
1081 | row["JacketItem"] = appearance.JacketItem.ToString(); | ||
1082 | row["JacketAsset"] = appearance.JacketAsset.ToString(); | ||
1083 | row["GlovesItem"] = appearance.GlovesItem.ToString(); | ||
1084 | row["GlovesAsset"] = appearance.GlovesAsset.ToString(); | ||
1085 | row["UnderShirtItem"] = appearance.UnderShirtItem.ToString(); | ||
1086 | row["UnderShirtAsset"] = appearance.UnderShirtAsset.ToString(); | ||
1087 | row["UnderPantsItem"] = appearance.UnderPantsItem.ToString(); | ||
1088 | row["UnderPantsAsset"] = appearance.UnderPantsAsset.ToString(); | ||
1089 | row["SkirtItem"] = appearance.SkirtItem.ToString(); | ||
1090 | row["SkirtAsset"] = appearance.SkirtAsset.ToString(); | ||
1091 | |||
1092 | // Used Base64String because for some reason it wont accept using Byte[] (which works in Region date) | ||
1093 | row["Texture"] = Convert.ToBase64String(appearance.Texture.GetBytes()); | ||
1094 | row["VisualParams"] = Convert.ToBase64String(appearance.VisualParams); | ||
1095 | |||
1096 | row["Serial"] = appearance.Serial; | ||
1097 | row["AvatarHeight"] = appearance.AvatarHeight; | ||
1098 | |||
1099 | // ADO.NET doesn't handle NULL very well | ||
1100 | foreach (DataColumn col in ds.Tables["avatarappearance"].Columns) | ||
1101 | { | ||
1102 | if (row[col] == null) | ||
1103 | { | ||
1104 | row[col] = String.Empty; | ||
1105 | } | ||
1106 | } | ||
1107 | } | ||
1108 | |||
1109 | /// <summary> | ||
1110 | /// | ||
1111 | /// </summary> | ||
1112 | /// <param name="row"></param> | ||
1113 | /// <returns></returns> | ||
1114 | private static UserAgentData buildUserAgent(DataRow row) | ||
1115 | { | ||
1116 | UserAgentData ua = new UserAgentData(); | ||
1117 | |||
1118 | UUID tmp; | ||
1119 | UUID.TryParse((String)row["UUID"], out tmp); | ||
1120 | ua.ProfileID = tmp; | ||
1121 | ua.AgentIP = (String)row["agentIP"]; | ||
1122 | ua.AgentPort = Convert.ToUInt32(row["agentPort"]); | ||
1123 | ua.AgentOnline = Convert.ToBoolean(row["agentOnline"]); | ||
1124 | ua.SessionID = new UUID((String) row["sessionID"]); | ||
1125 | ua.SecureSessionID = new UUID((String) row["secureSessionID"]); | ||
1126 | ua.InitialRegion = new UUID((String) row["regionID"]); | ||
1127 | ua.LoginTime = Convert.ToInt32(row["loginTime"]); | ||
1128 | ua.LogoutTime = Convert.ToInt32(row["logoutTime"]); | ||
1129 | ua.Region = new UUID((String) row["currentRegion"]); | ||
1130 | ua.Handle = Convert.ToUInt64(row["currentHandle"]); | ||
1131 | ua.Position = new Vector3( | ||
1132 | Convert.ToSingle(row["currentPosX"]), | ||
1133 | Convert.ToSingle(row["currentPosY"]), | ||
1134 | Convert.ToSingle(row["currentPosZ"]) | ||
1135 | ); | ||
1136 | ua.LookAt = new Vector3( | ||
1137 | Convert.ToSingle(row["currentLookAtX"]), | ||
1138 | Convert.ToSingle(row["currentLookAtY"]), | ||
1139 | Convert.ToSingle(row["currentLookAtZ"]) | ||
1140 | ); | ||
1141 | return ua; | ||
1142 | } | ||
1143 | |||
1144 | /// <summary> | ||
1145 | /// | ||
1146 | /// </summary> | ||
1147 | /// <param name="row"></param> | ||
1148 | /// <param name="ua"></param> | ||
1149 | private static void fillUserAgentRow(DataRow row, UserAgentData ua) | ||
1150 | { | ||
1151 | row["UUID"] = ua.ProfileID.ToString(); | ||
1152 | row["agentIP"] = ua.AgentIP; | ||
1153 | row["agentPort"] = ua.AgentPort; | ||
1154 | row["agentOnline"] = ua.AgentOnline; | ||
1155 | row["sessionID"] = ua.SessionID.ToString(); | ||
1156 | row["secureSessionID"] = ua.SecureSessionID.ToString(); | ||
1157 | row["regionID"] = ua.InitialRegion.ToString(); | ||
1158 | row["loginTime"] = ua.LoginTime; | ||
1159 | row["logoutTime"] = ua.LogoutTime; | ||
1160 | row["currentRegion"] = ua.Region.ToString(); | ||
1161 | row["currentHandle"] = ua.Handle.ToString(); | ||
1162 | // vectors | ||
1163 | row["currentPosX"] = ua.Position.X; | ||
1164 | row["currentPosY"] = ua.Position.Y; | ||
1165 | row["currentPosZ"] = ua.Position.Z; | ||
1166 | row["currentLookAtX"] = ua.LookAt.X; | ||
1167 | row["currentLookAtY"] = ua.LookAt.Y; | ||
1168 | row["currentLookAtZ"] = ua.LookAt.Z; | ||
1169 | } | ||
1170 | |||
1171 | /*********************************************************************** | ||
1172 | * | ||
1173 | * Database Binding functions | ||
1174 | * | ||
1175 | * These will be db specific due to typing, and minor differences | ||
1176 | * in databases. | ||
1177 | * | ||
1178 | **********************************************************************/ | ||
1179 | |||
1180 | /// <summary> | ||
1181 | /// | ||
1182 | /// </summary> | ||
1183 | /// <param name="da"></param> | ||
1184 | /// <param name="conn"></param> | ||
1185 | private void setupUserCommands(SqliteDataAdapter da, SqliteConnection conn) | ||
1186 | { | ||
1187 | da.InsertCommand = SQLiteUtil.createInsertCommand("users", ds.Tables["users"]); | ||
1188 | da.InsertCommand.Connection = conn; | ||
1189 | |||
1190 | da.UpdateCommand = SQLiteUtil.createUpdateCommand("users", "UUID=:UUID", ds.Tables["users"]); | ||
1191 | da.UpdateCommand.Connection = conn; | ||
1192 | |||
1193 | SqliteCommand delete = new SqliteCommand("delete from users where UUID = :UUID"); | ||
1194 | delete.Parameters.Add(SQLiteUtil.createSqliteParameter("UUID", typeof(String))); | ||
1195 | delete.Connection = conn; | ||
1196 | da.DeleteCommand = delete; | ||
1197 | } | ||
1198 | |||
1199 | private void setupAgentCommands(SqliteDataAdapter da, SqliteConnection conn) | ||
1200 | { | ||
1201 | da.InsertCommand = SQLiteUtil.createInsertCommand("useragents", ds.Tables["useragents"]); | ||
1202 | da.InsertCommand.Connection = conn; | ||
1203 | |||
1204 | da.UpdateCommand = SQLiteUtil.createUpdateCommand("useragents", "UUID=:UUID", ds.Tables["useragents"]); | ||
1205 | da.UpdateCommand.Connection = conn; | ||
1206 | |||
1207 | SqliteCommand delete = new SqliteCommand("delete from useragents where UUID = :ProfileID"); | ||
1208 | delete.Parameters.Add(SQLiteUtil.createSqliteParameter("ProfileID", typeof(String))); | ||
1209 | delete.Connection = conn; | ||
1210 | da.DeleteCommand = delete; | ||
1211 | } | ||
1212 | |||
1213 | /// <summary> | ||
1214 | /// | ||
1215 | /// </summary> | ||
1216 | /// <param name="daf"></param> | ||
1217 | /// <param name="conn"></param> | ||
1218 | private void setupUserFriendsCommands(SqliteDataAdapter daf, SqliteConnection conn) | ||
1219 | { | ||
1220 | daf.InsertCommand = SQLiteUtil.createInsertCommand("userfriends", ds.Tables["userfriends"]); | ||
1221 | daf.InsertCommand.Connection = conn; | ||
1222 | |||
1223 | daf.UpdateCommand = SQLiteUtil.createUpdateCommand("userfriends", "ownerID=:ownerID and friendID=:friendID", ds.Tables["userfriends"]); | ||
1224 | daf.UpdateCommand.Connection = conn; | ||
1225 | |||
1226 | SqliteCommand delete = new SqliteCommand("delete from userfriends where ownerID=:ownerID and friendID=:friendID"); | ||
1227 | delete.Parameters.Add(SQLiteUtil.createSqliteParameter("ownerID", typeof(String))); | ||
1228 | delete.Parameters.Add(SQLiteUtil.createSqliteParameter("friendID", typeof(String))); | ||
1229 | delete.Connection = conn; | ||
1230 | daf.DeleteCommand = delete; | ||
1231 | |||
1232 | } | ||
1233 | |||
1234 | /// <summary> | ||
1235 | /// | ||
1236 | /// </summary> | ||
1237 | /// <param name="daf"></param> | ||
1238 | /// <param name="conn"></param> | ||
1239 | private void setupAvatarAppearanceCommands(SqliteDataAdapter daa, SqliteConnection conn) | ||
1240 | { | ||
1241 | daa.InsertCommand = SQLiteUtil.createInsertCommand("avatarappearance", ds.Tables["avatarappearance"]); | ||
1242 | daa.InsertCommand.Connection = conn; | ||
1243 | |||
1244 | daa.UpdateCommand = SQLiteUtil.createUpdateCommand("avatarappearance", "Owner=:Owner", ds.Tables["avatarappearance"]); | ||
1245 | daa.UpdateCommand.Connection = conn; | ||
1246 | |||
1247 | SqliteCommand delete = new SqliteCommand("delete from avatarappearance where Owner=:Owner"); | ||
1248 | delete.Parameters.Add(SQLiteUtil.createSqliteParameter("Owner", typeof(String))); | ||
1249 | delete.Connection = conn; | ||
1250 | daa.DeleteCommand = delete; | ||
1251 | } | ||
1252 | |||
1253 | |||
1254 | override public void ResetAttachments(UUID userID) | ||
1255 | { | ||
1256 | } | ||
1257 | |||
1258 | override public void LogoutUsers(UUID regionID) | ||
1259 | { | ||
1260 | } | ||
1261 | } | ||
1262 | } | ||
diff --git a/OpenSim/Data/SQLite/SQLiteXInventoryData.cs b/OpenSim/Data/SQLite/SQLiteXInventoryData.cs index 5c93f88..a66e0c6 100644 --- a/OpenSim/Data/SQLite/SQLiteXInventoryData.cs +++ b/OpenSim/Data/SQLite/SQLiteXInventoryData.cs | |||
@@ -115,7 +115,7 @@ namespace OpenSim.Data.SQLite | |||
115 | cmd.Parameters.Add(new SqliteParameter(":ParentFolderID", newParent)); | 115 | cmd.Parameters.Add(new SqliteParameter(":ParentFolderID", newParent)); |
116 | cmd.Parameters.Add(new SqliteParameter(":InventoryID", id)); | 116 | cmd.Parameters.Add(new SqliteParameter(":InventoryID", id)); |
117 | 117 | ||
118 | return ExecuteNonQuery(cmd) == 0 ? false : true; | 118 | return ExecuteNonQuery(cmd, m_Connection) == 0 ? false : true; |
119 | } | 119 | } |
120 | 120 | ||
121 | public XInventoryItem[] GetActiveGestures(UUID principalID) | 121 | public XInventoryItem[] GetActiveGestures(UUID principalID) |
@@ -137,7 +137,7 @@ namespace OpenSim.Data.SQLite | |||
137 | cmd.Parameters.Add(new SqliteParameter(":PrincipalID", principalID.ToString())); | 137 | cmd.Parameters.Add(new SqliteParameter(":PrincipalID", principalID.ToString())); |
138 | cmd.Parameters.Add(new SqliteParameter(":AssetID", assetID.ToString())); | 138 | cmd.Parameters.Add(new SqliteParameter(":AssetID", assetID.ToString())); |
139 | 139 | ||
140 | IDataReader reader = ExecuteReader(cmd); | 140 | IDataReader reader = ExecuteReader(cmd, m_Connection); |
141 | 141 | ||
142 | int perms = 0; | 142 | int perms = 0; |
143 | 143 | ||
@@ -147,7 +147,7 @@ namespace OpenSim.Data.SQLite | |||
147 | } | 147 | } |
148 | 148 | ||
149 | reader.Close(); | 149 | reader.Close(); |
150 | CloseReaderCommand(cmd); | 150 | CloseCommand(cmd); |
151 | 151 | ||
152 | return perms; | 152 | return perms; |
153 | } | 153 | } |
diff --git a/OpenSim/Data/Tests/BasicAssetTest.cs b/OpenSim/Data/Tests/BasicAssetTest.cs index 58a17c2..9ec294d 100644 --- a/OpenSim/Data/Tests/BasicAssetTest.cs +++ b/OpenSim/Data/Tests/BasicAssetTest.cs | |||
@@ -73,17 +73,23 @@ namespace OpenSim.Data.Tests | |||
73 | a2.Data = asset1; | 73 | a2.Data = asset1; |
74 | a3.Data = asset1; | 74 | a3.Data = asset1; |
75 | 75 | ||
76 | a1.Metadata.ContentType = "application/octet-stream"; | ||
77 | a2.Metadata.ContentType = "application/octet-stream"; | ||
78 | a3.Metadata.ContentType = "application/octet-stream"; | ||
79 | |||
76 | PropertyScrambler<AssetBase> scrambler = new PropertyScrambler<AssetBase>() | 80 | PropertyScrambler<AssetBase> scrambler = new PropertyScrambler<AssetBase>() |
77 | .DontScramble(x => x.Data) | 81 | .DontScramble(x => x.Data) |
78 | .DontScramble(x => x.ID) | 82 | .DontScramble(x => x.ID) |
79 | .DontScramble(x => x.FullID) | 83 | .DontScramble(x => x.FullID) |
80 | .DontScramble(x => x.Metadata.ID) | 84 | .DontScramble(x => x.Metadata.ID) |
85 | .DontScramble(x => x.Metadata.ContentType) | ||
81 | .DontScramble(x => x.Metadata.FullID); | 86 | .DontScramble(x => x.Metadata.FullID); |
82 | 87 | ||
83 | scrambler.Scramble(a1); | 88 | scrambler.Scramble(a1); |
84 | scrambler.Scramble(a2); | 89 | scrambler.Scramble(a2); |
85 | scrambler.Scramble(a3); | 90 | scrambler.Scramble(a3); |
86 | 91 | ||
92 | |||
87 | db.StoreAsset(a1); | 93 | db.StoreAsset(a1); |
88 | db.StoreAsset(a2); | 94 | db.StoreAsset(a2); |
89 | db.StoreAsset(a3); | 95 | db.StoreAsset(a3); |
diff --git a/OpenSim/Data/Tests/BasicGridTest.cs b/OpenSim/Data/Tests/BasicGridTest.cs deleted file mode 100644 index df6c669..0000000 --- a/OpenSim/Data/Tests/BasicGridTest.cs +++ /dev/null | |||
@@ -1,173 +0,0 @@ | |||
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.Text; | ||
31 | using NUnit.Framework; | ||
32 | using NUnit.Framework.SyntaxHelpers; | ||
33 | using OpenMetaverse; | ||
34 | |||
35 | namespace OpenSim.Data.Tests | ||
36 | { | ||
37 | public class BasicGridTest | ||
38 | { | ||
39 | public IGridDataPlugin db; | ||
40 | public UUID region1, region2, region3; | ||
41 | public UUID zero = UUID.Zero; | ||
42 | public static Random random = new Random(); | ||
43 | |||
44 | [TearDown] | ||
45 | public void removeAllRegions() | ||
46 | { | ||
47 | // Clean up all the regions. | ||
48 | List<RegionProfileData> regions = db.GetRegionsByName("", 100); | ||
49 | if (regions != null) | ||
50 | { | ||
51 | foreach (RegionProfileData region in regions) | ||
52 | { | ||
53 | db.DeleteProfile(region.Uuid.ToString()); | ||
54 | } | ||
55 | } | ||
56 | } | ||
57 | |||
58 | public void SuperInit() | ||
59 | { | ||
60 | OpenSim.Tests.Common.TestLogging.LogToConsole(); | ||
61 | region1 = UUID.Random(); | ||
62 | region2 = UUID.Random(); | ||
63 | region3 = UUID.Random(); | ||
64 | } | ||
65 | |||
66 | protected RegionProfileData createRegion(UUID regionUUID, string regionName) | ||
67 | { | ||
68 | RegionProfileData reg = new RegionProfileData(); | ||
69 | new PropertyScrambler<RegionProfileData>().Scramble(reg); | ||
70 | reg.Uuid = regionUUID; | ||
71 | reg.RegionName = regionName; | ||
72 | |||
73 | db.StoreProfile(reg); | ||
74 | |||
75 | return reg; | ||
76 | } | ||
77 | |||
78 | [Test] | ||
79 | public void T001_LoadEmpty() | ||
80 | { | ||
81 | Assert.That(db.GetProfileByUUID(region1),Is.Null); | ||
82 | Assert.That(db.GetProfileByUUID(region2),Is.Null); | ||
83 | Assert.That(db.GetProfileByUUID(region3),Is.Null); | ||
84 | Assert.That(db.GetProfileByUUID(zero),Is.Null); | ||
85 | } | ||
86 | |||
87 | [Test] | ||
88 | public void T011_AddRetrieveCompleteTest() | ||
89 | { | ||
90 | RegionProfileData newreg = createRegion(region2, "|<Goth@m Ci1y>|"); | ||
91 | RegionProfileData retreg = db.GetProfileByUUID(region2); | ||
92 | |||
93 | Assert.That(retreg, Constraints.PropertyCompareConstraint(newreg).IgnoreProperty(x => x.RegionOnline)); | ||
94 | |||
95 | retreg = db.GetProfileByHandle(newreg.RegionHandle); | ||
96 | Assert.That(retreg.Uuid, Is.EqualTo(region2), "Assert.That(retreg.Uuid, Is.EqualTo(region2))"); | ||
97 | |||
98 | retreg = db.GetProfileByString(newreg.RegionName); | ||
99 | Assert.That(retreg.Uuid, Is.EqualTo(region2), "Assert.That(retreg.Uuid, Is.EqualTo(region2))"); | ||
100 | |||
101 | RegionProfileData[] retregs = db.GetProfilesInRange(newreg.RegionLocX,newreg.RegionLocY,newreg.RegionLocX,newreg.RegionLocY); | ||
102 | Assert.That(retregs[0].Uuid, Is.EqualTo(region2), "Assert.That(retregs[0].Uuid, Is.EqualTo(region2))"); | ||
103 | } | ||
104 | |||
105 | [Test] | ||
106 | public void T012_DeleteProfile() | ||
107 | { | ||
108 | createRegion(region1, "doesn't matter"); | ||
109 | |||
110 | db.DeleteProfile(region1.ToString()); | ||
111 | RegionProfileData retreg = db.GetProfileByUUID(region1); | ||
112 | Assert.That(retreg,Is.Null); | ||
113 | } | ||
114 | |||
115 | [Test] | ||
116 | public void T013_UpdateProfile() | ||
117 | { | ||
118 | createRegion(region2, "|<Goth@m Ci1y>|"); | ||
119 | |||
120 | RegionProfileData retreg = db.GetProfileByUUID(region2); | ||
121 | retreg.regionName = "Gotham City"; | ||
122 | |||
123 | db.StoreProfile(retreg); | ||
124 | |||
125 | retreg = db.GetProfileByUUID(region2); | ||
126 | Assert.That(retreg.RegionName, Is.EqualTo("Gotham City"), "Assert.That(retreg.RegionName, Is.EqualTo(\"Gotham City\"))"); | ||
127 | } | ||
128 | |||
129 | [Test] | ||
130 | public void T014_RegionList() | ||
131 | { | ||
132 | createRegion(region2, "Gotham City"); | ||
133 | |||
134 | RegionProfileData retreg = db.GetProfileByUUID(region2); | ||
135 | retreg.RegionName = "Gotham Town"; | ||
136 | retreg.Uuid = region1; | ||
137 | |||
138 | db.StoreProfile(retreg); | ||
139 | |||
140 | retreg = db.GetProfileByUUID(region2); | ||
141 | retreg.RegionName = "Gothan Town"; | ||
142 | retreg.Uuid = region3; | ||
143 | |||
144 | db.StoreProfile(retreg); | ||
145 | |||
146 | List<RegionProfileData> listreg = db.GetRegionsByName("Gotham",10); | ||
147 | |||
148 | Assert.That(listreg.Count,Is.EqualTo(2), "Assert.That(listreg.Count,Is.EqualTo(2))"); | ||
149 | Assert.That(listreg[0].Uuid,Is.Not.EqualTo(listreg[1].Uuid), "Assert.That(listreg[0].Uuid,Is.Not.EqualTo(listreg[1].Uuid))"); | ||
150 | Assert.That(listreg[0].Uuid, Is.EqualTo(region1) | Is.EqualTo(region2), "Assert.That(listreg[0].Uuid, Is.EqualTo(region1) | Is.EqualTo(region2))"); | ||
151 | Assert.That(listreg[1].Uuid, Is.EqualTo(region1) | Is.EqualTo(region2), "Assert.That(listreg[1].Uuid, Is.EqualTo(region1) | Is.EqualTo(region2))"); | ||
152 | } | ||
153 | |||
154 | [Test] | ||
155 | public void T999_StillNull() | ||
156 | { | ||
157 | Assert.That(db.GetProfileByUUID(zero), Is.Null); | ||
158 | } | ||
159 | |||
160 | protected static string RandomName() | ||
161 | { | ||
162 | StringBuilder name = new StringBuilder(); | ||
163 | int size = random.Next(5,12); | ||
164 | char ch ; | ||
165 | for (int i=0; i<size; i++) | ||
166 | { | ||
167 | ch = Convert.ToChar(Convert.ToInt32(Math.Floor(26 * random.NextDouble() + 65))) ; | ||
168 | name.Append(ch); | ||
169 | } | ||
170 | return name.ToString(); | ||
171 | } | ||
172 | } | ||
173 | } | ||
diff --git a/OpenSim/Data/Tests/BasicRegionTest.cs b/OpenSim/Data/Tests/BasicRegionTest.cs index 676c6ba..dfbf522 100644 --- a/OpenSim/Data/Tests/BasicRegionTest.cs +++ b/OpenSim/Data/Tests/BasicRegionTest.cs | |||
@@ -524,7 +524,7 @@ namespace OpenSim.Data.Tests | |||
524 | } | 524 | } |
525 | } | 525 | } |
526 | 526 | ||
527 | [Test] | 527 | //[Test] |
528 | public void T016_RandomSogWithSceneParts() | 528 | public void T016_RandomSogWithSceneParts() |
529 | { | 529 | { |
530 | PropertyScrambler<SceneObjectPart> scrambler = | 530 | PropertyScrambler<SceneObjectPart> scrambler = |
diff --git a/OpenSim/Data/Tests/BasicUserTest.cs b/OpenSim/Data/Tests/BasicUserTest.cs deleted file mode 100644 index d3b6041..0000000 --- a/OpenSim/Data/Tests/BasicUserTest.cs +++ /dev/null | |||
@@ -1,703 +0,0 @@ | |||
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 | // TODO: Money Transfer, Inventory Transfer and UpdateUserRegion once they exist | ||
29 | |||
30 | using System; | ||
31 | using System.Collections.Generic; | ||
32 | using System.Text; | ||
33 | using log4net.Config; | ||
34 | using NUnit.Framework; | ||
35 | using NUnit.Framework.SyntaxHelpers; | ||
36 | using OpenMetaverse; | ||
37 | using OpenSim.Framework; | ||
38 | using log4net; | ||
39 | using System.Reflection; | ||
40 | |||
41 | namespace OpenSim.Data.Tests | ||
42 | { | ||
43 | public class BasicUserTest | ||
44 | { | ||
45 | //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
46 | public IUserDataPlugin db; | ||
47 | public UUID user1; | ||
48 | public UUID user2; | ||
49 | public UUID user3; | ||
50 | public UUID user4; | ||
51 | public UUID user5; | ||
52 | public UUID webkey; | ||
53 | public UUID zero = UUID.Zero; | ||
54 | public static Random random; | ||
55 | |||
56 | public UUID agent1; | ||
57 | public UUID agent2; | ||
58 | public UUID agent3; | ||
59 | public UUID agent4; | ||
60 | |||
61 | public UUID region1; | ||
62 | |||
63 | public string fname0; | ||
64 | public string lname0; | ||
65 | public string fname1; | ||
66 | public string lname1; | ||
67 | public string fname2; | ||
68 | public string lname2; | ||
69 | public string fname3; | ||
70 | public string lname3; | ||
71 | |||
72 | public void SuperInit() | ||
73 | { | ||
74 | OpenSim.Tests.Common.TestLogging.LogToConsole(); | ||
75 | random = new Random(); | ||
76 | user1 = UUID.Random(); | ||
77 | user2 = UUID.Random(); | ||
78 | user3 = UUID.Random(); | ||
79 | user4 = UUID.Random(); | ||
80 | user5 = UUID.Random(); | ||
81 | agent1 = UUID.Random(); | ||
82 | agent2 = UUID.Random(); | ||
83 | agent3 = UUID.Random(); | ||
84 | agent4 = UUID.Random(); | ||
85 | webkey = UUID.Random(); | ||
86 | region1 = UUID.Random(); | ||
87 | fname0 = RandomName(); | ||
88 | lname0 = RandomName(); | ||
89 | fname1 = RandomName(); | ||
90 | lname1 = RandomName(); | ||
91 | fname2 = RandomName(); | ||
92 | lname2 = RandomName(); | ||
93 | fname3 = RandomName(); | ||
94 | lname3 = RandomName(); | ||
95 | } | ||
96 | |||
97 | [Test] | ||
98 | public void T001_LoadEmpty() | ||
99 | { | ||
100 | Assert.That(db.GetUserByUUID(zero), Is.Null); | ||
101 | Assert.That(db.GetUserByUUID(user1), Is.Null); | ||
102 | Assert.That(db.GetUserByUUID(user2), Is.Null); | ||
103 | Assert.That(db.GetUserByUUID(user3), Is.Null); | ||
104 | Assert.That(db.GetUserByUUID(UUID.Random()), Is.Null); | ||
105 | |||
106 | Assert.That(db.GetAgentByUUID(zero), Is.Null); | ||
107 | Assert.That(db.GetAgentByUUID(agent1), Is.Null); | ||
108 | Assert.That(db.GetAgentByUUID(agent2), Is.Null); | ||
109 | Assert.That(db.GetAgentByUUID(agent3), Is.Null); | ||
110 | Assert.That(db.GetAgentByUUID(UUID.Random()), Is.Null); | ||
111 | } | ||
112 | |||
113 | [Test] | ||
114 | public void T010_CreateUser() | ||
115 | { | ||
116 | UserProfileData u1 = NewUser(user1,fname1,lname1); | ||
117 | UserProfileData u2 = NewUser(user2,fname2,lname2); | ||
118 | UserProfileData u3 = NewUser(user3,fname3,lname3); | ||
119 | // this is used to check whether null works here | ||
120 | u3.Email = null; | ||
121 | |||
122 | db.AddNewUserProfile(u1); | ||
123 | db.AddNewUserProfile(u2); | ||
124 | db.AddNewUserProfile(u3); | ||
125 | UserProfileData u1a = db.GetUserByUUID(user1); | ||
126 | UserProfileData u2a = db.GetUserByUUID(user2); | ||
127 | UserProfileData u3a = db.GetUserByUUID(user3); | ||
128 | Assert.That(user1,Is.EqualTo(u1a.ID), "Assert.That(user1,Is.EqualTo(u1a.ID))"); | ||
129 | Assert.That(user2,Is.EqualTo(u2a.ID), "Assert.That(user2,Is.EqualTo(u2a.ID))"); | ||
130 | Assert.That(user3,Is.EqualTo(u3a.ID), "Assert.That(user3,Is.EqualTo(u3a.ID))"); | ||
131 | |||
132 | // and one email test | ||
133 | Assert.That(u3.Email, Is.Null); | ||
134 | } | ||
135 | |||
136 | [Test] | ||
137 | public void T011_FetchUserByName() | ||
138 | { | ||
139 | UserProfileData u1 = db.GetUserByName(fname1,lname1); | ||
140 | UserProfileData u2 = db.GetUserByName(fname2,lname2); | ||
141 | UserProfileData u3 = db.GetUserByName(fname3,lname3); | ||
142 | Assert.That(user1,Is.EqualTo(u1.ID), "Assert.That(user1,Is.EqualTo(u1.ID))"); | ||
143 | Assert.That(user2,Is.EqualTo(u2.ID), "Assert.That(user2,Is.EqualTo(u2.ID))"); | ||
144 | Assert.That(user3,Is.EqualTo(u3.ID), "Assert.That(user3,Is.EqualTo(u3.ID))"); | ||
145 | } | ||
146 | |||
147 | [Test] | ||
148 | public void T012_UpdateUserProfile() | ||
149 | { | ||
150 | UserProfileData u1 = db.GetUserByUUID(user1); | ||
151 | Assert.That(fname1,Is.EqualTo(u1.FirstName), "Assert.That(fname1,Is.EqualTo(u1.FirstName))"); | ||
152 | u1.FirstName = "Ugly"; | ||
153 | |||
154 | db.UpdateUserProfile(u1); | ||
155 | Assert.That("Ugly",Is.EqualTo(u1.FirstName), "Assert.That(\"Ugly\",Is.EqualTo(u1.FirstName))"); | ||
156 | } | ||
157 | |||
158 | [Test] | ||
159 | public void T013_StoreUserWebKey() | ||
160 | { | ||
161 | UserProfileData u1 = db.GetUserByUUID(user1); | ||
162 | Assert.That(u1.WebLoginKey,Is.EqualTo(zero), "Assert.That(u1.WebLoginKey,Is.EqualTo(zero))"); | ||
163 | db.StoreWebLoginKey(user1, webkey); | ||
164 | u1 = db.GetUserByUUID(user1); | ||
165 | Assert.That(u1.WebLoginKey,Is.EqualTo(webkey), "Assert.That(u1.WebLoginKey,Is.EqualTo(webkey))"); | ||
166 | } | ||
167 | |||
168 | [Test] | ||
169 | public void T014_ExpectedNullReferenceReturns() | ||
170 | { | ||
171 | UserProfileData u0 = NewUser(zero,fname0,lname0); | ||
172 | UserProfileData u4 = NewUser(user4,fname2,lname2); | ||
173 | db.AddNewUserProfile(u0); //UserID 0 should fail to save. | ||
174 | db.AddNewUserProfile(u4); //The first name and last name are already in use (from T010), so this should fail too | ||
175 | Assert.That(db.GetUserByUUID(zero),Is.Null); | ||
176 | Assert.That(db.GetUserByUUID(user4),Is.Null); | ||
177 | } | ||
178 | |||
179 | [Test] | ||
180 | public void T015_UserPersistency() | ||
181 | { | ||
182 | UserProfileData u = new UserProfileData(); | ||
183 | UUID id = user5; | ||
184 | string fname = RandomName(); | ||
185 | string lname = RandomName(); | ||
186 | string email = RandomName(); | ||
187 | string passhash = RandomName(); | ||
188 | string passsalt = RandomName(); | ||
189 | UUID homeregion = UUID.Random(); | ||
190 | UUID webloginkey = UUID.Random(); | ||
191 | uint homeregx = (uint) random.Next(); | ||
192 | uint homeregy = (uint) random.Next(); | ||
193 | Vector3 homeloc | ||
194 | = new Vector3( | ||
195 | (float)Math.Round(random.NextDouble(), 5), | ||
196 | (float)Math.Round(random.NextDouble(), 5), | ||
197 | (float)Math.Round(random.NextDouble(), 5)); | ||
198 | Vector3 homelookat | ||
199 | = new Vector3( | ||
200 | (float)Math.Round(random.NextDouble(), 5), | ||
201 | (float)Math.Round(random.NextDouble(), 5), | ||
202 | (float)Math.Round(random.NextDouble(), 5)); | ||
203 | int created = random.Next(); | ||
204 | int lastlogin = random.Next(); | ||
205 | string userinvuri = RandomName(); | ||
206 | string userasseturi = RandomName(); | ||
207 | uint candomask = (uint) random.Next(); | ||
208 | uint wantdomask = (uint) random.Next(); | ||
209 | string abouttext = RandomName(); | ||
210 | string flabouttext = RandomName(); | ||
211 | UUID image = UUID.Random(); | ||
212 | UUID firstimage = UUID.Random(); | ||
213 | UserAgentData agent = NewAgent(id,UUID.Random()); | ||
214 | int userflags = random.Next(); | ||
215 | int godlevel = random.Next(); | ||
216 | string customtype = RandomName(); | ||
217 | UUID partner = UUID.Random(); | ||
218 | |||
219 | //HomeRegionX and HomeRegionY must only use 24 bits | ||
220 | homeregx = ((homeregx << 8) >> 8); | ||
221 | homeregy = ((homeregy << 8) >> 8); | ||
222 | |||
223 | u.ID = id; | ||
224 | u.WebLoginKey = webloginkey; | ||
225 | u.HomeRegionID = homeregion; | ||
226 | u.FirstName = fname; | ||
227 | u.SurName = lname; | ||
228 | u.Email = email; | ||
229 | u.PasswordHash = passhash; | ||
230 | u.PasswordSalt = passsalt; | ||
231 | u.HomeRegionX = homeregx; | ||
232 | u.HomeRegionY = homeregy; | ||
233 | ulong homereg = u.HomeRegion; | ||
234 | u.HomeLocation = homeloc; | ||
235 | u.HomeLookAt = homelookat; | ||
236 | u.Created = created; | ||
237 | u.LastLogin = lastlogin; | ||
238 | u.UserInventoryURI = userinvuri; | ||
239 | u.UserAssetURI = userasseturi; | ||
240 | u.CanDoMask = candomask; | ||
241 | u.WantDoMask = wantdomask; | ||
242 | u.AboutText = abouttext; | ||
243 | u.FirstLifeAboutText = flabouttext; | ||
244 | u.Image = image; | ||
245 | u.FirstLifeImage = firstimage; | ||
246 | u.CurrentAgent = agent; | ||
247 | u.UserFlags = userflags; | ||
248 | u.GodLevel = godlevel; | ||
249 | u.CustomType = customtype; | ||
250 | u.Partner = partner; | ||
251 | |||
252 | db.AddNewUserProfile(u); | ||
253 | UserProfileData u1a = db.GetUserByUUID(id); | ||
254 | Assert.That(u1a,Is.Not.Null); | ||
255 | Assert.That(id,Is.EqualTo(u1a.ID), "Assert.That(id,Is.EqualTo(u1a.ID))"); | ||
256 | Assert.That(homeregion,Is.EqualTo(u1a.HomeRegionID), "Assert.That(homeregion,Is.EqualTo(u1a.HomeRegionID))"); | ||
257 | Assert.That(webloginkey,Is.EqualTo(u1a.WebLoginKey), "Assert.That(webloginkey,Is.EqualTo(u1a.WebLoginKey))"); | ||
258 | Assert.That(fname,Is.EqualTo(u1a.FirstName), "Assert.That(fname,Is.EqualTo(u1a.FirstName))"); | ||
259 | Assert.That(lname,Is.EqualTo(u1a.SurName), "Assert.That(lname,Is.EqualTo(u1a.SurName))"); | ||
260 | Assert.That(email,Is.EqualTo(u1a.Email), "Assert.That(email,Is.EqualTo(u1a.Email))"); | ||
261 | Assert.That(passhash,Is.EqualTo(u1a.PasswordHash), "Assert.That(passhash,Is.EqualTo(u1a.PasswordHash))"); | ||
262 | Assert.That(passsalt,Is.EqualTo(u1a.PasswordSalt), "Assert.That(passsalt,Is.EqualTo(u1a.PasswordSalt))"); | ||
263 | Assert.That(homeregx,Is.EqualTo(u1a.HomeRegionX), "Assert.That(homeregx,Is.EqualTo(u1a.HomeRegionX))"); | ||
264 | Assert.That(homeregy,Is.EqualTo(u1a.HomeRegionY), "Assert.That(homeregy,Is.EqualTo(u1a.HomeRegionY))"); | ||
265 | Assert.That(homereg,Is.EqualTo(u1a.HomeRegion), "Assert.That(homereg,Is.EqualTo(u1a.HomeRegion))"); | ||
266 | Assert.That(homeloc,Is.EqualTo(u1a.HomeLocation), "Assert.That(homeloc,Is.EqualTo(u1a.HomeLocation))"); | ||
267 | Assert.That(homelookat,Is.EqualTo(u1a.HomeLookAt), "Assert.That(homelookat,Is.EqualTo(u1a.HomeLookAt))"); | ||
268 | Assert.That(created,Is.EqualTo(u1a.Created), "Assert.That(created,Is.EqualTo(u1a.Created))"); | ||
269 | Assert.That(lastlogin,Is.EqualTo(u1a.LastLogin), "Assert.That(lastlogin,Is.EqualTo(u1a.LastLogin))"); | ||
270 | Assert.That(userinvuri,Is.EqualTo(u1a.UserInventoryURI), "Assert.That(userinvuri,Is.EqualTo(u1a.UserInventoryURI))"); | ||
271 | Assert.That(userasseturi,Is.EqualTo(u1a.UserAssetURI), "Assert.That(userasseturi,Is.EqualTo(u1a.UserAssetURI))"); | ||
272 | Assert.That(candomask,Is.EqualTo(u1a.CanDoMask), "Assert.That(candomask,Is.EqualTo(u1a.CanDoMask))"); | ||
273 | Assert.That(wantdomask,Is.EqualTo(u1a.WantDoMask), "Assert.That(wantdomask,Is.EqualTo(u1a.WantDoMask))"); | ||
274 | Assert.That(abouttext,Is.EqualTo(u1a.AboutText), "Assert.That(abouttext,Is.EqualTo(u1a.AboutText))"); | ||
275 | Assert.That(flabouttext,Is.EqualTo(u1a.FirstLifeAboutText), "Assert.That(flabouttext,Is.EqualTo(u1a.FirstLifeAboutText))"); | ||
276 | Assert.That(image,Is.EqualTo(u1a.Image), "Assert.That(image,Is.EqualTo(u1a.Image))"); | ||
277 | Assert.That(firstimage,Is.EqualTo(u1a.FirstLifeImage), "Assert.That(firstimage,Is.EqualTo(u1a.FirstLifeImage))"); | ||
278 | Assert.That(u1a.CurrentAgent,Is.Null); | ||
279 | Assert.That(userflags,Is.EqualTo(u1a.UserFlags), "Assert.That(userflags,Is.EqualTo(u1a.UserFlags))"); | ||
280 | Assert.That(godlevel,Is.EqualTo(u1a.GodLevel), "Assert.That(godlevel,Is.EqualTo(u1a.GodLevel))"); | ||
281 | Assert.That(customtype,Is.EqualTo(u1a.CustomType), "Assert.That(customtype,Is.EqualTo(u1a.CustomType))"); | ||
282 | Assert.That(partner,Is.EqualTo(u1a.Partner), "Assert.That(partner,Is.EqualTo(u1a.Partner))"); | ||
283 | } | ||
284 | |||
285 | [Test] | ||
286 | public void T016_UserUpdatePersistency() | ||
287 | { | ||
288 | UUID id = user5; | ||
289 | UserProfileData u = db.GetUserByUUID(id); | ||
290 | string fname = RandomName(); | ||
291 | string lname = RandomName(); | ||
292 | string email = RandomName(); | ||
293 | string passhash = RandomName(); | ||
294 | string passsalt = RandomName(); | ||
295 | UUID homeregionid = UUID.Random(); | ||
296 | UUID webloginkey = UUID.Random(); | ||
297 | uint homeregx = (uint) random.Next(); | ||
298 | uint homeregy = (uint) random.Next(); | ||
299 | Vector3 homeloc = new Vector3((float)Math.Round(random.NextDouble(),5),(float)Math.Round(random.NextDouble(),5),(float)Math.Round(random.NextDouble(),5)); | ||
300 | Vector3 homelookat = new Vector3((float)Math.Round(random.NextDouble(),5),(float)Math.Round(random.NextDouble(),5),(float)Math.Round(random.NextDouble(),5)); | ||
301 | int created = random.Next(); | ||
302 | int lastlogin = random.Next(); | ||
303 | string userinvuri = RandomName(); | ||
304 | string userasseturi = RandomName(); | ||
305 | uint candomask = (uint) random.Next(); | ||
306 | uint wantdomask = (uint) random.Next(); | ||
307 | string abouttext = RandomName(); | ||
308 | string flabouttext = RandomName(); | ||
309 | UUID image = UUID.Random(); | ||
310 | UUID firstimage = UUID.Random(); | ||
311 | UserAgentData agent = NewAgent(id,UUID.Random()); | ||
312 | int userflags = random.Next(); | ||
313 | int godlevel = random.Next(); | ||
314 | string customtype = RandomName(); | ||
315 | UUID partner = UUID.Random(); | ||
316 | |||
317 | //HomeRegionX and HomeRegionY must only use 24 bits | ||
318 | homeregx = ((homeregx << 8) >> 8); | ||
319 | homeregy = ((homeregy << 8) >> 8); | ||
320 | |||
321 | u.WebLoginKey = webloginkey; | ||
322 | u.HomeRegionID = homeregionid; | ||
323 | u.FirstName = fname; | ||
324 | u.SurName = lname; | ||
325 | u.Email = email; | ||
326 | u.PasswordHash = passhash; | ||
327 | u.PasswordSalt = passsalt; | ||
328 | u.HomeRegionX = homeregx; | ||
329 | u.HomeRegionY = homeregy; | ||
330 | ulong homereg = u.HomeRegion; | ||
331 | u.HomeLocation = homeloc; | ||
332 | u.HomeLookAt = homelookat; | ||
333 | u.Created = created; | ||
334 | u.LastLogin = lastlogin; | ||
335 | u.UserInventoryURI = userinvuri; | ||
336 | u.UserAssetURI = userasseturi; | ||
337 | u.CanDoMask = candomask; | ||
338 | u.WantDoMask = wantdomask; | ||
339 | u.AboutText = abouttext; | ||
340 | u.FirstLifeAboutText = flabouttext; | ||
341 | u.Image = image; | ||
342 | u.FirstLifeImage = firstimage; | ||
343 | u.CurrentAgent = agent; | ||
344 | u.UserFlags = userflags; | ||
345 | u.GodLevel = godlevel; | ||
346 | u.CustomType = customtype; | ||
347 | u.Partner = partner; | ||
348 | |||
349 | db.UpdateUserProfile(u); | ||
350 | UserProfileData u1a = db.GetUserByUUID(id); | ||
351 | Assert.That(u1a,Is.Not.Null); | ||
352 | Assert.That(id,Is.EqualTo(u1a.ID), "Assert.That(id,Is.EqualTo(u1a.ID))"); | ||
353 | Assert.That(homeregionid,Is.EqualTo(u1a.HomeRegionID), "Assert.That(homeregionid,Is.EqualTo(u1a.HomeRegionID))"); | ||
354 | Assert.That(webloginkey,Is.EqualTo(u1a.WebLoginKey), "Assert.That(webloginkey,Is.EqualTo(u1a.WebLoginKey))"); | ||
355 | Assert.That(fname,Is.EqualTo(u1a.FirstName), "Assert.That(fname,Is.EqualTo(u1a.FirstName))"); | ||
356 | Assert.That(lname,Is.EqualTo(u1a.SurName), "Assert.That(lname,Is.EqualTo(u1a.SurName))"); | ||
357 | Assert.That(email,Is.EqualTo(u1a.Email), "Assert.That(email,Is.EqualTo(u1a.Email))"); | ||
358 | Assert.That(passhash,Is.EqualTo(u1a.PasswordHash), "Assert.That(passhash,Is.EqualTo(u1a.PasswordHash))"); | ||
359 | Assert.That(passsalt,Is.EqualTo(u1a.PasswordSalt), "Assert.That(passsalt,Is.EqualTo(u1a.PasswordSalt))"); | ||
360 | Assert.That(homereg,Is.EqualTo(u1a.HomeRegion), "Assert.That(homereg,Is.EqualTo(u1a.HomeRegion))"); | ||
361 | Assert.That(homeregx,Is.EqualTo(u1a.HomeRegionX), "Assert.That(homeregx,Is.EqualTo(u1a.HomeRegionX))"); | ||
362 | Assert.That(homeregy,Is.EqualTo(u1a.HomeRegionY), "Assert.That(homeregy,Is.EqualTo(u1a.HomeRegionY))"); | ||
363 | Assert.That(homereg,Is.EqualTo(u1a.HomeRegion), "Assert.That(homereg,Is.EqualTo(u1a.HomeRegion))"); | ||
364 | Assert.That(homeloc,Is.EqualTo(u1a.HomeLocation), "Assert.That(homeloc,Is.EqualTo(u1a.HomeLocation))"); | ||
365 | Assert.That(homelookat,Is.EqualTo(u1a.HomeLookAt), "Assert.That(homelookat,Is.EqualTo(u1a.HomeLookAt))"); | ||
366 | Assert.That(created,Is.EqualTo(u1a.Created), "Assert.That(created,Is.EqualTo(u1a.Created))"); | ||
367 | Assert.That(lastlogin,Is.EqualTo(u1a.LastLogin), "Assert.That(lastlogin,Is.EqualTo(u1a.LastLogin))"); | ||
368 | Assert.That(userasseturi,Is.EqualTo(u1a.UserAssetURI), "Assert.That(userasseturi,Is.EqualTo(u1a.UserAssetURI))"); | ||
369 | Assert.That(candomask,Is.EqualTo(u1a.CanDoMask), "Assert.That(candomask,Is.EqualTo(u1a.CanDoMask))"); | ||
370 | Assert.That(wantdomask,Is.EqualTo(u1a.WantDoMask), "Assert.That(wantdomask,Is.EqualTo(u1a.WantDoMask))"); | ||
371 | Assert.That(abouttext,Is.EqualTo(u1a.AboutText), "Assert.That(abouttext,Is.EqualTo(u1a.AboutText))"); | ||
372 | Assert.That(flabouttext,Is.EqualTo(u1a.FirstLifeAboutText), "Assert.That(flabouttext,Is.EqualTo(u1a.FirstLifeAboutText))"); | ||
373 | Assert.That(image,Is.EqualTo(u1a.Image), "Assert.That(image,Is.EqualTo(u1a.Image))"); | ||
374 | Assert.That(firstimage,Is.EqualTo(u1a.FirstLifeImage), "Assert.That(firstimage,Is.EqualTo(u1a.FirstLifeImage))"); | ||
375 | Assert.That(u1a.CurrentAgent,Is.Null); | ||
376 | Assert.That(userflags,Is.EqualTo(u1a.UserFlags), "Assert.That(userflags,Is.EqualTo(u1a.UserFlags))"); | ||
377 | Assert.That(godlevel,Is.EqualTo(u1a.GodLevel), "Assert.That(godlevel,Is.EqualTo(u1a.GodLevel))"); | ||
378 | Assert.That(customtype,Is.EqualTo(u1a.CustomType), "Assert.That(customtype,Is.EqualTo(u1a.CustomType))"); | ||
379 | Assert.That(partner,Is.EqualTo(u1a.Partner), "Assert.That(partner,Is.EqualTo(u1a.Partner))"); | ||
380 | } | ||
381 | |||
382 | [Test] | ||
383 | public void T017_UserUpdateRandomPersistency() | ||
384 | { | ||
385 | UUID id = user5; | ||
386 | UserProfileData u = db.GetUserByUUID(id); | ||
387 | new PropertyScrambler<UserProfileData>().DontScramble(x=>x.ID).Scramble(u); | ||
388 | |||
389 | db.UpdateUserProfile(u); | ||
390 | UserProfileData u1a = db.GetUserByUUID(id); | ||
391 | Assert.That(u1a, Constraints.PropertyCompareConstraint(u) | ||
392 | .IgnoreProperty(x=>x.HomeRegionX) | ||
393 | .IgnoreProperty(x=>x.HomeRegionY) | ||
394 | ); | ||
395 | } | ||
396 | |||
397 | [Test] | ||
398 | public void T020_CreateAgent() | ||
399 | { | ||
400 | UserAgentData a1 = NewAgent(user1,agent1); | ||
401 | UserAgentData a2 = NewAgent(user2,agent2); | ||
402 | UserAgentData a3 = NewAgent(user3,agent3); | ||
403 | db.AddNewUserAgent(a1); | ||
404 | db.AddNewUserAgent(a2); | ||
405 | db.AddNewUserAgent(a3); | ||
406 | UserAgentData a1a = db.GetAgentByUUID(user1); | ||
407 | UserAgentData a2a = db.GetAgentByUUID(user2); | ||
408 | UserAgentData a3a = db.GetAgentByUUID(user3); | ||
409 | Assert.That(agent1,Is.EqualTo(a1a.SessionID), "Assert.That(agent1,Is.EqualTo(a1a.SessionID))"); | ||
410 | Assert.That(user1,Is.EqualTo(a1a.ProfileID), "Assert.That(user1,Is.EqualTo(a1a.ProfileID))"); | ||
411 | Assert.That(agent2,Is.EqualTo(a2a.SessionID), "Assert.That(agent2,Is.EqualTo(a2a.SessionID))"); | ||
412 | Assert.That(user2,Is.EqualTo(a2a.ProfileID), "Assert.That(user2,Is.EqualTo(a2a.ProfileID))"); | ||
413 | Assert.That(agent3,Is.EqualTo(a3a.SessionID), "Assert.That(agent3,Is.EqualTo(a3a.SessionID))"); | ||
414 | Assert.That(user3,Is.EqualTo(a3a.ProfileID), "Assert.That(user3,Is.EqualTo(a3a.ProfileID))"); | ||
415 | } | ||
416 | |||
417 | [Test] | ||
418 | public void T021_FetchAgentByName() | ||
419 | { | ||
420 | String name3 = fname3 + " " + lname3; | ||
421 | UserAgentData a2 = db.GetAgentByName(fname2,lname2); | ||
422 | UserAgentData a3 = db.GetAgentByName(name3); | ||
423 | Assert.That(user2,Is.EqualTo(a2.ProfileID), "Assert.That(user2,Is.EqualTo(a2.ProfileID))"); | ||
424 | Assert.That(user3,Is.EqualTo(a3.ProfileID), "Assert.That(user3,Is.EqualTo(a3.ProfileID))"); | ||
425 | } | ||
426 | |||
427 | [Test] | ||
428 | public void T022_ExceptionalCases() | ||
429 | { | ||
430 | UserAgentData a0 = NewAgent(user4,zero); | ||
431 | UserAgentData a4 = NewAgent(zero,agent4); | ||
432 | db.AddNewUserAgent(a0); | ||
433 | db.AddNewUserAgent(a4); | ||
434 | |||
435 | Assert.That(db.GetAgentByUUID(user4),Is.Null); | ||
436 | Assert.That(db.GetAgentByUUID(zero),Is.Null); | ||
437 | } | ||
438 | |||
439 | [Test] | ||
440 | public void T023_AgentPersistency() | ||
441 | { | ||
442 | UUID user = user4; | ||
443 | UUID agent = agent4; | ||
444 | UUID secureagent = UUID.Random(); | ||
445 | string agentip = RandomName(); | ||
446 | uint agentport = (uint)random.Next(); | ||
447 | bool agentonline = (random.NextDouble() > 0.5); | ||
448 | int logintime = random.Next(); | ||
449 | int logouttime = random.Next(); | ||
450 | UUID regionid = UUID.Random(); | ||
451 | ulong regionhandle = (ulong) random.Next(); | ||
452 | Vector3 currentpos = new Vector3((float)Math.Round(random.NextDouble(),5),(float)Math.Round(random.NextDouble(),5),(float)Math.Round(random.NextDouble(),5)); | ||
453 | Vector3 currentlookat = new Vector3((float)Math.Round(random.NextDouble(),5),(float)Math.Round(random.NextDouble(),5),(float)Math.Round(random.NextDouble(),5)); | ||
454 | UUID orgregionid = UUID.Random(); | ||
455 | |||
456 | UserAgentData a = new UserAgentData(); | ||
457 | a.ProfileID = user; | ||
458 | a.SessionID = agent; | ||
459 | a.SecureSessionID = secureagent; | ||
460 | a.AgentIP = agentip; | ||
461 | a.AgentPort = agentport; | ||
462 | a.AgentOnline = agentonline; | ||
463 | a.LoginTime = logintime; | ||
464 | a.LogoutTime = logouttime; | ||
465 | a.Region = regionid; | ||
466 | a.Handle = regionhandle; | ||
467 | a.Position = currentpos; | ||
468 | a.LookAt = currentlookat; | ||
469 | a.InitialRegion = orgregionid; | ||
470 | |||
471 | db.AddNewUserAgent(a); | ||
472 | |||
473 | UserAgentData a1 = db.GetAgentByUUID(user4); | ||
474 | Assert.That(user,Is.EqualTo(a1.ProfileID), "Assert.That(user,Is.EqualTo(a1.ProfileID))"); | ||
475 | Assert.That(agent,Is.EqualTo(a1.SessionID), "Assert.That(agent,Is.EqualTo(a1.SessionID))"); | ||
476 | Assert.That(secureagent,Is.EqualTo(a1.SecureSessionID), "Assert.That(secureagent,Is.EqualTo(a1.SecureSessionID))"); | ||
477 | Assert.That(agentip,Is.EqualTo(a1.AgentIP), "Assert.That(agentip,Is.EqualTo(a1.AgentIP))"); | ||
478 | Assert.That(agentport,Is.EqualTo(a1.AgentPort), "Assert.That(agentport,Is.EqualTo(a1.AgentPort))"); | ||
479 | Assert.That(agentonline,Is.EqualTo(a1.AgentOnline), "Assert.That(agentonline,Is.EqualTo(a1.AgentOnline))"); | ||
480 | Assert.That(logintime,Is.EqualTo(a1.LoginTime), "Assert.That(logintime,Is.EqualTo(a1.LoginTime))"); | ||
481 | Assert.That(logouttime,Is.EqualTo(a1.LogoutTime), "Assert.That(logouttime,Is.EqualTo(a1.LogoutTime))"); | ||
482 | Assert.That(regionid,Is.EqualTo(a1.Region), "Assert.That(regionid,Is.EqualTo(a1.Region))"); | ||
483 | Assert.That(regionhandle,Is.EqualTo(a1.Handle), "Assert.That(regionhandle,Is.EqualTo(a1.Handle))"); | ||
484 | Assert.That(currentpos,Is.EqualTo(a1.Position), "Assert.That(currentpos,Is.EqualTo(a1.Position))"); | ||
485 | Assert.That(currentlookat,Is.EqualTo(a1.LookAt), "Assert.That(currentlookat,Is.EqualTo(a1.LookAt))"); | ||
486 | } | ||
487 | |||
488 | [Test] | ||
489 | public void T030_CreateFriendList() | ||
490 | { | ||
491 | Dictionary<UUID, uint> perms = new Dictionary<UUID,uint>(); | ||
492 | Dictionary<UUID, int> friends = new Dictionary<UUID,int>(); | ||
493 | uint temp; | ||
494 | int tempu1, tempu2; | ||
495 | db.AddNewUserFriend(user1,user2, 1); | ||
496 | db.AddNewUserFriend(user1,user3, 2); | ||
497 | db.AddNewUserFriend(user1,user2, 4); | ||
498 | List<FriendListItem> fl1 = db.GetUserFriendList(user1); | ||
499 | Assert.That(fl1.Count,Is.EqualTo(2), "Assert.That(fl1.Count,Is.EqualTo(2))"); | ||
500 | perms.Add(user2,1); | ||
501 | perms.Add(user3,2); | ||
502 | for (int i = 0; i < fl1.Count; i++) | ||
503 | { | ||
504 | Assert.That(user1,Is.EqualTo(fl1[i].FriendListOwner), "Assert.That(user1,Is.EqualTo(fl1[i].FriendListOwner))"); | ||
505 | friends.Add(fl1[i].Friend,1); | ||
506 | temp = perms[fl1[i].Friend]; | ||
507 | Assert.That(temp,Is.EqualTo(fl1[i].FriendPerms), "Assert.That(temp,Is.EqualTo(fl1[i].FriendPerms))"); | ||
508 | } | ||
509 | tempu1 = friends[user2]; | ||
510 | tempu2 = friends[user3]; | ||
511 | Assert.That(1,Is.EqualTo(tempu1) & Is.EqualTo(tempu2), "Assert.That(1,Is.EqualTo(tempu1) & Is.EqualTo(tempu2))"); | ||
512 | } | ||
513 | |||
514 | [Test] | ||
515 | public void T031_RemoveUserFriend() | ||
516 | // user1 has 2 friends, user2 and user3. | ||
517 | { | ||
518 | List<FriendListItem> fl1 = db.GetUserFriendList(user1); | ||
519 | List<FriendListItem> fl2 = db.GetUserFriendList(user2); | ||
520 | |||
521 | Assert.That(fl1.Count,Is.EqualTo(2), "Assert.That(fl1.Count,Is.EqualTo(2))"); | ||
522 | Assert.That(fl1[0].Friend,Is.EqualTo(user2) | Is.EqualTo(user3), "Assert.That(fl1[0].Friend,Is.EqualTo(user2) | Is.EqualTo(user3))"); | ||
523 | Assert.That(fl2[0].Friend,Is.EqualTo(user1), "Assert.That(fl2[0].Friend,Is.EqualTo(user1))"); | ||
524 | db.RemoveUserFriend(user2, user1); | ||
525 | |||
526 | fl1 = db.GetUserFriendList(user1); | ||
527 | fl2 = db.GetUserFriendList(user2); | ||
528 | Assert.That(fl1.Count,Is.EqualTo(1), "Assert.That(fl1.Count,Is.EqualTo(1))"); | ||
529 | Assert.That(fl1[0].Friend, Is.EqualTo(user3), "Assert.That(fl1[0].Friend, Is.EqualTo(user3))"); | ||
530 | Assert.That(fl2, Is.Empty); | ||
531 | } | ||
532 | |||
533 | [Test] | ||
534 | public void T032_UpdateFriendPerms() | ||
535 | // user1 has 1 friend, user3, who has permission 2 in T030. | ||
536 | { | ||
537 | List<FriendListItem> fl1 = db.GetUserFriendList(user1); | ||
538 | Assert.That(fl1[0].FriendPerms,Is.EqualTo(2), "Assert.That(fl1[0].FriendPerms,Is.EqualTo(2))"); | ||
539 | db.UpdateUserFriendPerms(user1, user3, 4); | ||
540 | |||
541 | fl1 = db.GetUserFriendList(user1); | ||
542 | Assert.That(fl1[0].FriendPerms,Is.EqualTo(4), "Assert.That(fl1[0].FriendPerms,Is.EqualTo(4))"); | ||
543 | } | ||
544 | |||
545 | [Test] | ||
546 | public void T040_UserAppearance() | ||
547 | { | ||
548 | AvatarAppearance appear = new AvatarAppearance(); | ||
549 | appear.Owner = user1; | ||
550 | db.UpdateUserAppearance(user1, appear); | ||
551 | AvatarAppearance user1app = db.GetUserAppearance(user1); | ||
552 | Assert.That(user1,Is.EqualTo(user1app.Owner), "Assert.That(user1,Is.EqualTo(user1app.Owner))"); | ||
553 | } | ||
554 | |||
555 | [Test] | ||
556 | public void T041_UserAppearancePersistency() | ||
557 | { | ||
558 | AvatarAppearance appear = new AvatarAppearance(); | ||
559 | UUID owner = UUID.Random(); | ||
560 | int serial = random.Next(); | ||
561 | byte[] visualp = new byte[218]; | ||
562 | random.NextBytes(visualp); | ||
563 | UUID bodyitem = UUID.Random(); | ||
564 | UUID bodyasset = UUID.Random(); | ||
565 | UUID skinitem = UUID.Random(); | ||
566 | UUID skinasset = UUID.Random(); | ||
567 | UUID hairitem = UUID.Random(); | ||
568 | UUID hairasset = UUID.Random(); | ||
569 | UUID eyesitem = UUID.Random(); | ||
570 | UUID eyesasset = UUID.Random(); | ||
571 | UUID shirtitem = UUID.Random(); | ||
572 | UUID shirtasset = UUID.Random(); | ||
573 | UUID pantsitem = UUID.Random(); | ||
574 | UUID pantsasset = UUID.Random(); | ||
575 | UUID shoesitem = UUID.Random(); | ||
576 | UUID shoesasset = UUID.Random(); | ||
577 | UUID socksitem = UUID.Random(); | ||
578 | UUID socksasset = UUID.Random(); | ||
579 | UUID jacketitem = UUID.Random(); | ||
580 | UUID jacketasset = UUID.Random(); | ||
581 | UUID glovesitem = UUID.Random(); | ||
582 | UUID glovesasset = UUID.Random(); | ||
583 | UUID ushirtitem = UUID.Random(); | ||
584 | UUID ushirtasset = UUID.Random(); | ||
585 | UUID upantsitem = UUID.Random(); | ||
586 | UUID upantsasset = UUID.Random(); | ||
587 | UUID skirtitem = UUID.Random(); | ||
588 | UUID skirtasset = UUID.Random(); | ||
589 | Primitive.TextureEntry texture = AvatarAppearance.GetDefaultTexture(); | ||
590 | float avatarheight = (float) (Math.Round(random.NextDouble(),5)); | ||
591 | |||
592 | appear.Owner = owner; | ||
593 | appear.Serial = serial; | ||
594 | appear.VisualParams = visualp; | ||
595 | appear.BodyItem = bodyitem; | ||
596 | appear.BodyAsset = bodyasset; | ||
597 | appear.SkinItem = skinitem; | ||
598 | appear.SkinAsset = skinasset; | ||
599 | appear.HairItem = hairitem; | ||
600 | appear.HairAsset = hairasset; | ||
601 | appear.EyesItem = eyesitem; | ||
602 | appear.EyesAsset = eyesasset; | ||
603 | appear.ShirtItem = shirtitem; | ||
604 | appear.ShirtAsset = shirtasset; | ||
605 | appear.PantsItem = pantsitem; | ||
606 | appear.PantsAsset = pantsasset; | ||
607 | appear.ShoesItem = shoesitem; | ||
608 | appear.ShoesAsset = shoesasset; | ||
609 | appear.SocksItem = socksitem; | ||
610 | appear.SocksAsset = socksasset; | ||
611 | appear.JacketItem = jacketitem; | ||
612 | appear.JacketAsset = jacketasset; | ||
613 | appear.GlovesItem = glovesitem; | ||
614 | appear.GlovesAsset = glovesasset; | ||
615 | appear.UnderShirtItem = ushirtitem; | ||
616 | appear.UnderShirtAsset = ushirtasset; | ||
617 | appear.UnderPantsItem = upantsitem; | ||
618 | appear.UnderPantsAsset = upantsasset; | ||
619 | appear.SkirtItem = skirtitem; | ||
620 | appear.SkirtAsset = skirtasset; | ||
621 | appear.Texture = texture; | ||
622 | appear.AvatarHeight = avatarheight; | ||
623 | |||
624 | db.UpdateUserAppearance(owner, appear); | ||
625 | AvatarAppearance app = db.GetUserAppearance(owner); | ||
626 | |||
627 | Assert.That(owner,Is.EqualTo(app.Owner), "Assert.That(owner,Is.EqualTo(app.Owner))"); | ||
628 | Assert.That(serial,Is.EqualTo(app.Serial), "Assert.That(serial,Is.EqualTo(app.Serial))"); | ||
629 | Assert.That(visualp,Is.EqualTo(app.VisualParams), "Assert.That(visualp,Is.EqualTo(app.VisualParams))"); | ||
630 | Assert.That(bodyitem,Is.EqualTo(app.BodyItem), "Assert.That(bodyitem,Is.EqualTo(app.BodyItem))"); | ||
631 | Assert.That(bodyasset,Is.EqualTo(app.BodyAsset), "Assert.That(bodyasset,Is.EqualTo(app.BodyAsset))"); | ||
632 | Assert.That(skinitem,Is.EqualTo(app.SkinItem), "Assert.That(skinitem,Is.EqualTo(app.SkinItem))"); | ||
633 | Assert.That(skinasset,Is.EqualTo(app.SkinAsset), "Assert.That(skinasset,Is.EqualTo(app.SkinAsset))"); | ||
634 | Assert.That(hairitem,Is.EqualTo(app.HairItem), "Assert.That(hairitem,Is.EqualTo(app.HairItem))"); | ||
635 | Assert.That(hairasset,Is.EqualTo(app.HairAsset), "Assert.That(hairasset,Is.EqualTo(app.HairAsset))"); | ||
636 | Assert.That(eyesitem,Is.EqualTo(app.EyesItem), "Assert.That(eyesitem,Is.EqualTo(app.EyesItem))"); | ||
637 | Assert.That(eyesasset,Is.EqualTo(app.EyesAsset), "Assert.That(eyesasset,Is.EqualTo(app.EyesAsset))"); | ||
638 | Assert.That(shirtitem,Is.EqualTo(app.ShirtItem), "Assert.That(shirtitem,Is.EqualTo(app.ShirtItem))"); | ||
639 | Assert.That(shirtasset,Is.EqualTo(app.ShirtAsset), "Assert.That(shirtasset,Is.EqualTo(app.ShirtAsset))"); | ||
640 | Assert.That(pantsitem,Is.EqualTo(app.PantsItem), "Assert.That(pantsitem,Is.EqualTo(app.PantsItem))"); | ||
641 | Assert.That(pantsasset,Is.EqualTo(app.PantsAsset), "Assert.That(pantsasset,Is.EqualTo(app.PantsAsset))"); | ||
642 | Assert.That(shoesitem,Is.EqualTo(app.ShoesItem), "Assert.That(shoesitem,Is.EqualTo(app.ShoesItem))"); | ||
643 | Assert.That(shoesasset,Is.EqualTo(app.ShoesAsset), "Assert.That(shoesasset,Is.EqualTo(app.ShoesAsset))"); | ||
644 | Assert.That(socksitem,Is.EqualTo(app.SocksItem), "Assert.That(socksitem,Is.EqualTo(app.SocksItem))"); | ||
645 | Assert.That(socksasset,Is.EqualTo(app.SocksAsset), "Assert.That(socksasset,Is.EqualTo(app.SocksAsset))"); | ||
646 | Assert.That(jacketitem,Is.EqualTo(app.JacketItem), "Assert.That(jacketitem,Is.EqualTo(app.JacketItem))"); | ||
647 | Assert.That(jacketasset,Is.EqualTo(app.JacketAsset), "Assert.That(jacketasset,Is.EqualTo(app.JacketAsset))"); | ||
648 | Assert.That(glovesitem,Is.EqualTo(app.GlovesItem), "Assert.That(glovesitem,Is.EqualTo(app.GlovesItem))"); | ||
649 | Assert.That(glovesasset,Is.EqualTo(app.GlovesAsset), "Assert.That(glovesasset,Is.EqualTo(app.GlovesAsset))"); | ||
650 | Assert.That(ushirtitem,Is.EqualTo(app.UnderShirtItem), "Assert.That(ushirtitem,Is.EqualTo(app.UnderShirtItem))"); | ||
651 | Assert.That(ushirtasset,Is.EqualTo(app.UnderShirtAsset), "Assert.That(ushirtasset,Is.EqualTo(app.UnderShirtAsset))"); | ||
652 | Assert.That(upantsitem,Is.EqualTo(app.UnderPantsItem), "Assert.That(upantsitem,Is.EqualTo(app.UnderPantsItem))"); | ||
653 | Assert.That(upantsasset,Is.EqualTo(app.UnderPantsAsset), "Assert.That(upantsasset,Is.EqualTo(app.UnderPantsAsset))"); | ||
654 | Assert.That(skirtitem,Is.EqualTo(app.SkirtItem), "Assert.That(skirtitem,Is.EqualTo(app.SkirtItem))"); | ||
655 | Assert.That(skirtasset,Is.EqualTo(app.SkirtAsset), "Assert.That(skirtasset,Is.EqualTo(app.SkirtAsset))"); | ||
656 | Assert.That(texture.ToString(),Is.EqualTo(app.Texture.ToString()), "Assert.That(texture.ToString(),Is.EqualTo(app.Texture.ToString()))"); | ||
657 | Assert.That(avatarheight,Is.EqualTo(app.AvatarHeight), "Assert.That(avatarheight,Is.EqualTo(app.AvatarHeight))"); | ||
658 | } | ||
659 | |||
660 | [Test] | ||
661 | public void T999_StillNull() | ||
662 | { | ||
663 | Assert.That(db.GetUserByUUID(zero), Is.Null); | ||
664 | Assert.That(db.GetAgentByUUID(zero), Is.Null); | ||
665 | } | ||
666 | |||
667 | public UserProfileData NewUser(UUID id,string fname,string lname) | ||
668 | { | ||
669 | UserProfileData u = new UserProfileData(); | ||
670 | u.ID = id; | ||
671 | u.FirstName = fname; | ||
672 | u.SurName = lname; | ||
673 | u.PasswordHash = "NOTAHASH"; | ||
674 | u.PasswordSalt = "NOTSALT"; | ||
675 | // MUST specify at least these 5 parameters or an exception is raised | ||
676 | |||
677 | return u; | ||
678 | } | ||
679 | |||
680 | public UserAgentData NewAgent(UUID user_profile, UUID agent) | ||
681 | { | ||
682 | UserAgentData a = new UserAgentData(); | ||
683 | a.ProfileID = user_profile; | ||
684 | a.SessionID = agent; | ||
685 | a.SecureSessionID = UUID.Random(); | ||
686 | a.AgentIP = RandomName(); | ||
687 | return a; | ||
688 | } | ||
689 | |||
690 | public static string RandomName() | ||
691 | { | ||
692 | StringBuilder name = new StringBuilder(); | ||
693 | int size = random.Next(5,12); | ||
694 | char ch ; | ||
695 | for (int i=0; i<size; i++) | ||
696 | { | ||
697 | ch = Convert.ToChar(Convert.ToInt32(Math.Floor(26 * random.NextDouble() + 65))) ; | ||
698 | name.Append(ch); | ||
699 | } | ||
700 | return name.ToString(); | ||
701 | } | ||
702 | } | ||
703 | } | ||
diff --git a/OpenSim/Data/UserDataBase.cs b/OpenSim/Data/UserDataBase.cs deleted file mode 100644 index 3d370da..0000000 --- a/OpenSim/Data/UserDataBase.cs +++ /dev/null | |||
@@ -1,91 +0,0 @@ | |||
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 OpenMetaverse; | ||
31 | using OpenSim.Framework; | ||
32 | |||
33 | namespace OpenSim.Data | ||
34 | { | ||
35 | public abstract class UserDataBase : IUserDataPlugin | ||
36 | { | ||
37 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
38 | |||
39 | // private Dictionary<UUID, AvatarAppearance> aplist = new Dictionary<UUID, AvatarAppearance>(); | ||
40 | |||
41 | public abstract UserProfileData GetUserByUUID(UUID user); | ||
42 | public abstract UserProfileData GetUserByName(string fname, string lname); | ||
43 | public abstract UserAgentData GetAgentByUUID(UUID user); | ||
44 | public abstract UserAgentData GetAgentByName(string name); | ||
45 | public abstract UserAgentData GetAgentByName(string fname, string lname); | ||
46 | public UserProfileData GetUserByUri(Uri uri) { return null; } | ||
47 | public abstract void StoreWebLoginKey(UUID agentID, UUID webLoginKey); | ||
48 | public abstract void AddNewUserProfile(UserProfileData user); | ||
49 | |||
50 | public virtual void AddTemporaryUserProfile(UserProfileData userProfile) | ||
51 | { | ||
52 | // Deliberately blank - database plugins shouldn't store temporary profiles. | ||
53 | } | ||
54 | |||
55 | public abstract bool UpdateUserProfile(UserProfileData user); | ||
56 | public abstract void AddNewUserAgent(UserAgentData agent); | ||
57 | public abstract void AddNewUserFriend(UUID friendlistowner, UUID friend, uint perms); | ||
58 | public abstract void RemoveUserFriend(UUID friendlistowner, UUID friend); | ||
59 | public abstract void UpdateUserFriendPerms(UUID friendlistowner, UUID friend, uint perms); | ||
60 | public abstract List<FriendListItem> GetUserFriendList(UUID friendlistowner); | ||
61 | public abstract Dictionary<UUID, FriendRegionInfo> GetFriendRegionInfos (List<UUID> uuids); | ||
62 | public abstract bool MoneyTransferRequest(UUID from, UUID to, uint amount); | ||
63 | public abstract bool InventoryTransferRequest(UUID from, UUID to, UUID inventory); | ||
64 | public abstract List<AvatarPickerAvatar> GeneratePickerResults(UUID queryID, string query); | ||
65 | public abstract AvatarAppearance GetUserAppearance(UUID user); | ||
66 | public abstract void UpdateUserAppearance(UUID user, AvatarAppearance appearance); | ||
67 | // public virtual AvatarAppearance GetUserAppearance(UUID user) { | ||
68 | // AvatarAppearance aa = null; | ||
69 | // try { | ||
70 | // aa = aplist[user]; | ||
71 | // m_log.Info("[APPEARANCE] Found appearance for " + user.ToString() + aa.ToString()); | ||
72 | // } catch (System.Collections.Generic.KeyNotFoundException e) { | ||
73 | // m_log.Info("[APPEARANCE] No appearance found for " + user.ToString()); | ||
74 | // } | ||
75 | // return aa; | ||
76 | // } | ||
77 | // public virtual void UpdateUserAppearance(UUID user, AvatarAppearance appearance) { | ||
78 | // aplist[user] = appearance; | ||
79 | // m_log.Info("[APPEARANCE] Setting appearance for " + user.ToString() + appearance.ToString()); | ||
80 | // } | ||
81 | public abstract void ResetAttachments(UUID userID); | ||
82 | |||
83 | public abstract void LogoutUsers(UUID regionID); | ||
84 | |||
85 | public abstract string Version {get;} | ||
86 | public abstract string Name {get;} | ||
87 | public abstract void Initialise(string connect); | ||
88 | public abstract void Initialise(); | ||
89 | public abstract void Dispose(); | ||
90 | } | ||
91 | } | ||
diff --git a/OpenSim/Framework/AvatarAppearance.cs b/OpenSim/Framework/AvatarAppearance.cs index c0e9891..5da8ba1 100644 --- a/OpenSim/Framework/AvatarAppearance.cs +++ b/OpenSim/Framework/AvatarAppearance.cs | |||
@@ -69,7 +69,7 @@ namespace OpenSim.Framework | |||
69 | private static UUID HAIR_ASSET = new UUID("d342e6c0-b9d2-11dc-95ff-0800200c9a66"); | 69 | private static UUID HAIR_ASSET = new UUID("d342e6c0-b9d2-11dc-95ff-0800200c9a66"); |
70 | private static UUID HAIR_ITEM = new UUID("d342e6c1-b9d2-11dc-95ff-0800200c9a66"); | 70 | private static UUID HAIR_ITEM = new UUID("d342e6c1-b9d2-11dc-95ff-0800200c9a66"); |
71 | 71 | ||
72 | public readonly static int VISUALPARAM_COUNT = 218; | 72 | public readonly static int VISUALPARAM_COUNT = 218; |
73 | 73 | ||
74 | protected UUID m_owner; | 74 | protected UUID m_owner; |
75 | 75 | ||
@@ -361,7 +361,7 @@ namespace OpenSim.Framework | |||
361 | // This sets Visual Params with *less* weirder values then default. Instead of a ugly alien, it looks like a fat scientist | 361 | // This sets Visual Params with *less* weirder values then default. Instead of a ugly alien, it looks like a fat scientist |
362 | SetDefaultParams(m_visualparams); | 362 | SetDefaultParams(m_visualparams); |
363 | SetDefaultWearables(); | 363 | SetDefaultWearables(); |
364 | m_texture = GetDefaultTexture(); | 364 | m_texture = GetDefaultTexture(); |
365 | } | 365 | } |
366 | 366 | ||
367 | public AvatarAppearance(UUID avatarID, AvatarWearable[] wearables, byte[] visualParams) | 367 | public AvatarAppearance(UUID avatarID, AvatarWearable[] wearables, byte[] visualParams) |
diff --git a/OpenSim/Framework/Communications/TemporaryUserProfilePlugin.cs b/OpenSim/Framework/Communications/TemporaryUserProfilePlugin.cs deleted file mode 100644 index 2413055..0000000 --- a/OpenSim/Framework/Communications/TemporaryUserProfilePlugin.cs +++ /dev/null | |||
@@ -1,104 +0,0 @@ | |||
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.Reflection; | ||
31 | using log4net; | ||
32 | using OpenMetaverse; | ||
33 | using OpenSim.Data; | ||
34 | |||
35 | namespace OpenSim.Framework.Communications | ||
36 | { | ||
37 | /// <summary> | ||
38 | /// Plugin for managing temporary user profiles. | ||
39 | /// </summary> | ||
40 | public class TemporaryUserProfilePlugin : IUserDataPlugin | ||
41 | { | ||
42 | //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
43 | |||
44 | protected Dictionary<UUID, UserProfileData> m_profiles = new Dictionary<UUID, UserProfileData>(); | ||
45 | |||
46 | public string Name { get { return "TemporaryUserProfilePlugin"; } } | ||
47 | public string Version { get { return "0.1"; } } | ||
48 | public void Initialise() {} | ||
49 | public void Initialise(string connect) {} | ||
50 | public void Dispose() {} | ||
51 | |||
52 | public UserProfileData GetUserByUUID(UUID user) | ||
53 | { | ||
54 | //m_log.DebugFormat("[TEMP USER PROFILE]: Received request for {0}", user); | ||
55 | |||
56 | lock (m_profiles) | ||
57 | { | ||
58 | if (m_profiles.ContainsKey(user)) | ||
59 | return m_profiles[user]; | ||
60 | else | ||
61 | return null; | ||
62 | } | ||
63 | } | ||
64 | |||
65 | public UserProfileData GetUserByName(string fname, string lname) | ||
66 | { | ||
67 | // We deliberately don't look up a temporary profile by name so that we don't obscure non-temporary | ||
68 | // profiles. | ||
69 | |||
70 | return null; | ||
71 | } | ||
72 | |||
73 | public virtual void AddTemporaryUserProfile(UserProfileData userProfile) | ||
74 | { | ||
75 | //m_log.DebugFormat("[TEMP USER PROFILE]: Adding {0} {1}", userProfile.Name, userProfile.ID); | ||
76 | |||
77 | lock (m_profiles) | ||
78 | { | ||
79 | m_profiles[userProfile.ID] = userProfile; | ||
80 | } | ||
81 | } | ||
82 | |||
83 | public UserProfileData GetUserByUri(Uri uri) { return null; } | ||
84 | public List<AvatarPickerAvatar> GeneratePickerResults(UUID queryID, string query) { return null; } | ||
85 | public UserAgentData GetAgentByUUID(UUID user) { return null; } | ||
86 | public UserAgentData GetAgentByName(string name) { return null; } | ||
87 | public UserAgentData GetAgentByName(string fname, string lname) { return null; } | ||
88 | public void StoreWebLoginKey(UUID agentID, UUID webLoginKey) {} | ||
89 | public void AddNewUserProfile(UserProfileData user) {} | ||
90 | public bool UpdateUserProfile(UserProfileData user) { return false; } | ||
91 | public void AddNewUserAgent(UserAgentData agent) {} | ||
92 | public void AddNewUserFriend(UUID friendlistowner, UUID friend, uint perms) {} | ||
93 | public void RemoveUserFriend(UUID friendlistowner, UUID friend) {} | ||
94 | public void UpdateUserFriendPerms(UUID friendlistowner, UUID friend, uint perms) {} | ||
95 | public List<FriendListItem> GetUserFriendList(UUID friendlistowner) { return null; } | ||
96 | public Dictionary<UUID, FriendRegionInfo> GetFriendRegionInfos(List<UUID> uuids) { return null; } | ||
97 | public bool MoneyTransferRequest(UUID from, UUID to, uint amount) { return false; } | ||
98 | public bool InventoryTransferRequest(UUID from, UUID to, UUID inventory) { return false; } | ||
99 | public AvatarAppearance GetUserAppearance(UUID user) { return null; } | ||
100 | public void UpdateUserAppearance(UUID user, AvatarAppearance appearance) {} | ||
101 | public void ResetAttachments(UUID userID) {} | ||
102 | public void LogoutUsers(UUID regionID) {} | ||
103 | } | ||
104 | } | ||
diff --git a/OpenSim/Framework/Console/LocalConsole.cs b/OpenSim/Framework/Console/LocalConsole.cs index b7e191b..be936b6 100644 --- a/OpenSim/Framework/Console/LocalConsole.cs +++ b/OpenSim/Framework/Console/LocalConsole.cs | |||
@@ -38,7 +38,7 @@ namespace OpenSim.Framework.Console | |||
38 | { | 38 | { |
39 | /// <summary> | 39 | /// <summary> |
40 | /// A console that uses cursor control and color | 40 | /// A console that uses cursor control and color |
41 | /// </summary> | 41 | /// </summary> |
42 | public class LocalConsole : CommandConsole | 42 | public class LocalConsole : CommandConsole |
43 | { | 43 | { |
44 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 44 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
@@ -100,8 +100,8 @@ namespace OpenSim.Framework.Console | |||
100 | private int SetCursorTop(int top) | 100 | private int SetCursorTop(int top) |
101 | { | 101 | { |
102 | // From at least mono 2.4.2.3, window resizing can give mono an invalid row and column values. If we try | 102 | // From at least mono 2.4.2.3, window resizing can give mono an invalid row and column values. If we try |
103 | // to set a cursor row position with a currently invalid column, mono will throw an exception. | 103 | // to set a cursor row position with a currently invalid column, mono will throw an exception. |
104 | // Therefore, we need to make sure that the column position is valid first. | 104 | // Therefore, we need to make sure that the column position is valid first. |
105 | int left = System.Console.CursorLeft; | 105 | int left = System.Console.CursorLeft; |
106 | 106 | ||
107 | if (left < 0) | 107 | if (left < 0) |
@@ -129,12 +129,12 @@ namespace OpenSim.Framework.Console | |||
129 | /// </param> | 129 | /// </param> |
130 | /// <returns> | 130 | /// <returns> |
131 | /// The new cursor column. | 131 | /// The new cursor column. |
132 | /// </returns> | 132 | /// </returns> |
133 | private int SetCursorLeft(int left) | 133 | private int SetCursorLeft(int left) |
134 | { | 134 | { |
135 | // From at least mono 2.4.2.3, window resizing can give mono an invalid row and column values. If we try | 135 | // From at least mono 2.4.2.3, window resizing can give mono an invalid row and column values. If we try |
136 | // to set a cursor column position with a currently invalid row, mono will throw an exception. | 136 | // to set a cursor column position with a currently invalid row, mono will throw an exception. |
137 | // Therefore, we need to make sure that the row position is valid first. | 137 | // Therefore, we need to make sure that the row position is valid first. |
138 | int top = System.Console.CursorTop; | 138 | int top = System.Console.CursorTop; |
139 | 139 | ||
140 | if (top < 0) | 140 | if (top < 0) |
@@ -183,7 +183,7 @@ namespace OpenSim.Framework.Console | |||
183 | System.Console.Write("{0}", prompt); | 183 | System.Console.Write("{0}", prompt); |
184 | 184 | ||
185 | SetCursorTop(new_y); | 185 | SetCursorTop(new_y); |
186 | SetCursorLeft(new_x); | 186 | SetCursorLeft(new_x); |
187 | } | 187 | } |
188 | } | 188 | } |
189 | 189 | ||
diff --git a/OpenSim/Framework/Console/RemoteConsole.cs b/OpenSim/Framework/Console/RemoteConsole.cs index 9fdd1b8..6f8348d 100644 --- a/OpenSim/Framework/Console/RemoteConsole.cs +++ b/OpenSim/Framework/Console/RemoteConsole.cs | |||
@@ -302,9 +302,9 @@ namespace OpenSim.Framework.Console | |||
302 | if (!UUID.TryParse(post["ID"].ToString(), out id)) | 302 | if (!UUID.TryParse(post["ID"].ToString(), out id)) |
303 | return reply; | 303 | return reply; |
304 | 304 | ||
305 | lock(m_Connections) | 305 | lock (m_Connections) |
306 | { | 306 | { |
307 | if(!m_Connections.ContainsKey(id)) | 307 | if (!m_Connections.ContainsKey(id)) |
308 | return reply; | 308 | return reply; |
309 | } | 309 | } |
310 | 310 | ||
diff --git a/OpenSim/Framework/RegionInfo.cs b/OpenSim/Framework/RegionInfo.cs index 0a826a6..ac38ac2 100644 --- a/OpenSim/Framework/RegionInfo.cs +++ b/OpenSim/Framework/RegionInfo.cs | |||
@@ -483,7 +483,6 @@ namespace OpenSim.Framework | |||
483 | else | 483 | else |
484 | m_externalHostName = externalName; | 484 | m_externalHostName = externalName; |
485 | 485 | ||
486 | |||
487 | m_regionType = config.GetString("RegionType", String.Empty); | 486 | m_regionType = config.GetString("RegionType", String.Empty); |
488 | 487 | ||
489 | // Prim stuff | 488 | // Prim stuff |
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index 2fc7adc..10af925 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs | |||
@@ -589,11 +589,17 @@ namespace OpenSim.Framework | |||
589 | 589 | ||
590 | public static IPAddress GetLocalHost() | 590 | public static IPAddress GetLocalHost() |
591 | { | 591 | { |
592 | string dnsAddress = "localhost"; | 592 | IPAddress[] iplist = GetLocalHosts(); |
593 | 593 | ||
594 | IPAddress[] hosts = Dns.GetHostEntry(dnsAddress).AddressList; | 594 | if (iplist.Length == 0) // No accessible external interfaces |
595 | { | ||
596 | IPAddress[] loopback = Dns.GetHostAddresses("localhost"); | ||
597 | IPAddress localhost = loopback[0]; | ||
595 | 598 | ||
596 | foreach (IPAddress host in hosts) | 599 | return localhost; |
600 | } | ||
601 | |||
602 | foreach (IPAddress host in iplist) | ||
597 | { | 603 | { |
598 | if (!IPAddress.IsLoopback(host) && host.AddressFamily == AddressFamily.InterNetwork) | 604 | if (!IPAddress.IsLoopback(host) && host.AddressFamily == AddressFamily.InterNetwork) |
599 | { | 605 | { |
@@ -601,15 +607,15 @@ namespace OpenSim.Framework | |||
601 | } | 607 | } |
602 | } | 608 | } |
603 | 609 | ||
604 | if (hosts.Length > 0) | 610 | if (iplist.Length > 0) |
605 | { | 611 | { |
606 | foreach (IPAddress host in hosts) | 612 | foreach (IPAddress host in iplist) |
607 | { | 613 | { |
608 | if (host.AddressFamily == AddressFamily.InterNetwork) | 614 | if (host.AddressFamily == AddressFamily.InterNetwork) |
609 | return host; | 615 | return host; |
610 | } | 616 | } |
611 | // Well all else failed... | 617 | // Well all else failed... |
612 | return hosts[0]; | 618 | return iplist[0]; |
613 | } | 619 | } |
614 | 620 | ||
615 | return null; | 621 | return null; |
diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs index acd6a14..7e81650 100755 --- a/OpenSim/Region/Application/OpenSim.cs +++ b/OpenSim/Region/Application/OpenSim.cs | |||
@@ -194,6 +194,8 @@ namespace OpenSim | |||
194 | 194 | ||
195 | PrintFileToConsole("startuplogo.txt"); | 195 | PrintFileToConsole("startuplogo.txt"); |
196 | 196 | ||
197 | m_log.InfoFormat("[NETWORK]: Using {0} as SYSTEMIP", Util.GetLocalHost().ToString()); | ||
198 | |||
197 | // For now, start at the 'root' level by default | 199 | // For now, start at the 'root' level by default |
198 | if (m_sceneManager.Scenes.Count == 1) // If there is only one region, select it | 200 | if (m_sceneManager.Scenes.Count == 1) // If there is only one region, select it |
199 | ChangeSelectedRegion("region", | 201 | ChangeSelectedRegion("region", |
@@ -417,7 +419,7 @@ namespace OpenSim | |||
417 | // kick client... | 419 | // kick client... |
418 | if (alert != null) | 420 | if (alert != null) |
419 | presence.ControllingClient.Kick(alert); | 421 | presence.ControllingClient.Kick(alert); |
420 | else | 422 | else |
421 | presence.ControllingClient.Kick("\nThe OpenSim manager kicked you out.\n"); | 423 | presence.ControllingClient.Kick("\nThe OpenSim manager kicked you out.\n"); |
422 | 424 | ||
423 | // ...and close on our side | 425 | // ...and close on our side |
@@ -624,7 +626,6 @@ namespace OpenSim | |||
624 | } | 626 | } |
625 | } | 627 | } |
626 | 628 | ||
627 | |||
628 | /// <summary> | 629 | /// <summary> |
629 | /// Load, Unload, and list Region modules in use | 630 | /// Load, Unload, and list Region modules in use |
630 | /// </summary> | 631 | /// </summary> |
@@ -924,7 +925,6 @@ namespace OpenSim | |||
924 | scene.RegionInfo.RegionLocX, | 925 | scene.RegionInfo.RegionLocX, |
925 | scene.RegionInfo.RegionLocY, | 926 | scene.RegionInfo.RegionLocY, |
926 | scene.RegionInfo.InternalEndPoint.Port)); | 927 | scene.RegionInfo.InternalEndPoint.Port)); |
927 | |||
928 | }); | 928 | }); |
929 | break; | 929 | break; |
930 | 930 | ||
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index 1f5946b..afc5270 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs | |||
@@ -5224,7 +5224,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
5224 | args.Type = ChatTypeEnum.Shout; | 5224 | args.Type = ChatTypeEnum.Shout; |
5225 | args.Position = new Vector3(); | 5225 | args.Position = new Vector3(); |
5226 | args.Scene = Scene; | 5226 | args.Scene = Scene; |
5227 | args.Sender = this; | 5227 | args.Sender = this; |
5228 | ChatMessage handlerChatFromClient2 = OnChatFromClient; | 5228 | ChatMessage handlerChatFromClient2 = OnChatFromClient; |
5229 | if (handlerChatFromClient2 != null) | 5229 | if (handlerChatFromClient2 != null) |
5230 | handlerChatFromClient2(this, args); | 5230 | handlerChatFromClient2(this, args); |
@@ -11036,4855 +11036,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
11036 | /// <param name="Pack">OpenMetaverse.packet</param> | 11036 | /// <param name="Pack">OpenMetaverse.packet</param> |
11037 | public void ProcessInPacket(Packet Pack) | 11037 | public void ProcessInPacket(Packet Pack) |
11038 | { | 11038 | { |
11039 | 11039 | // m_log.DebugFormat("[CLIENT]: Packet IN {0}", Pack); | |
11040 | if (ProcessPacketMethod(Pack)) | ||
11041 | { | ||
11042 | PacketPool.Instance.ReturnPacket(Pack); | ||
11043 | return; | ||
11044 | } | ||
11045 | |||
11046 | // Main packet processing conditional | ||
11047 | switch (Pack.Type) | ||
11048 | { | ||
11049 | #region CommentedOut | ||
11050 | /* | ||
11051 | #region Scene/Avatar | ||
11052 | |||
11053 | |||
11054 | case PacketType.AvatarPropertiesRequest: | ||
11055 | AvatarPropertiesRequestPacket avatarProperties = (AvatarPropertiesRequestPacket)Pack; | ||
11056 | |||
11057 | #region Packet Session and User Check | ||
11058 | if (m_checkPackets) | ||
11059 | { | ||
11060 | if (avatarProperties.AgentData.SessionID != SessionId || | ||
11061 | avatarProperties.AgentData.AgentID != AgentId) | ||
11062 | break; | ||
11063 | } | ||
11064 | #endregion | ||
11065 | |||
11066 | RequestAvatarProperties handlerRequestAvatarProperties = OnRequestAvatarProperties; | ||
11067 | if (handlerRequestAvatarProperties != null) | ||
11068 | { | ||
11069 | handlerRequestAvatarProperties(this, avatarProperties.AgentData.AvatarID); | ||
11070 | } | ||
11071 | |||
11072 | break; | ||
11073 | |||
11074 | case PacketType.ChatFromViewer: | ||
11075 | ChatFromViewerPacket inchatpack = (ChatFromViewerPacket)Pack; | ||
11076 | |||
11077 | #region Packet Session and User Check | ||
11078 | if (m_checkPackets) | ||
11079 | { | ||
11080 | if (inchatpack.AgentData.SessionID != SessionId || | ||
11081 | inchatpack.AgentData.AgentID != AgentId) | ||
11082 | break; | ||
11083 | } | ||
11084 | #endregion | ||
11085 | |||
11086 | string fromName = String.Empty; //ClientAvatar.firstname + " " + ClientAvatar.lastname; | ||
11087 | byte[] message = inchatpack.ChatData.Message; | ||
11088 | byte type = inchatpack.ChatData.Type; | ||
11089 | Vector3 fromPos = new Vector3(); // ClientAvatar.Pos; | ||
11090 | // UUID fromAgentID = AgentId; | ||
11091 | |||
11092 | int channel = inchatpack.ChatData.Channel; | ||
11093 | |||
11094 | if (OnChatFromClient != null) | ||
11095 | { | ||
11096 | OSChatMessage args = new OSChatMessage(); | ||
11097 | args.Channel = channel; | ||
11098 | args.From = fromName; | ||
11099 | args.Message = Utils.BytesToString(message); | ||
11100 | args.Type = (ChatTypeEnum)type; | ||
11101 | args.Position = fromPos; | ||
11102 | |||
11103 | args.Scene = Scene; | ||
11104 | args.Sender = this; | ||
11105 | args.SenderUUID = this.AgentId; | ||
11106 | |||
11107 | ChatMessage handlerChatFromClient = OnChatFromClient; | ||
11108 | if (handlerChatFromClient != null) | ||
11109 | handlerChatFromClient(this, args); | ||
11110 | } | ||
11111 | break; | ||
11112 | |||
11113 | case PacketType.AvatarPropertiesUpdate: | ||
11114 | AvatarPropertiesUpdatePacket avatarProps = (AvatarPropertiesUpdatePacket)Pack; | ||
11115 | |||
11116 | #region Packet Session and User Check | ||
11117 | if (m_checkPackets) | ||
11118 | { | ||
11119 | if (avatarProps.AgentData.SessionID != SessionId || | ||
11120 | avatarProps.AgentData.AgentID != AgentId) | ||
11121 | break; | ||
11122 | } | ||
11123 | #endregion | ||
11124 | |||
11125 | UpdateAvatarProperties handlerUpdateAvatarProperties = OnUpdateAvatarProperties; | ||
11126 | if (handlerUpdateAvatarProperties != null) | ||
11127 | { | ||
11128 | AvatarPropertiesUpdatePacket.PropertiesDataBlock Properties = avatarProps.PropertiesData; | ||
11129 | UserProfileData UserProfile = new UserProfileData(); | ||
11130 | UserProfile.ID = AgentId; | ||
11131 | UserProfile.AboutText = Utils.BytesToString(Properties.AboutText); | ||
11132 | UserProfile.FirstLifeAboutText = Utils.BytesToString(Properties.FLAboutText); | ||
11133 | UserProfile.FirstLifeImage = Properties.FLImageID; | ||
11134 | UserProfile.Image = Properties.ImageID; | ||
11135 | UserProfile.ProfileUrl = Utils.BytesToString(Properties.ProfileURL); | ||
11136 | |||
11137 | handlerUpdateAvatarProperties(this, UserProfile); | ||
11138 | } | ||
11139 | break; | ||
11140 | |||
11141 | case PacketType.ScriptDialogReply: | ||
11142 | ScriptDialogReplyPacket rdialog = (ScriptDialogReplyPacket)Pack; | ||
11143 | |||
11144 | #region Packet Session and User Check | ||
11145 | if (m_checkPackets) | ||
11146 | { | ||
11147 | if (rdialog.AgentData.SessionID != SessionId || | ||
11148 | rdialog.AgentData.AgentID != AgentId) | ||
11149 | break; | ||
11150 | } | ||
11151 | #endregion | ||
11152 | |||
11153 | int ch = rdialog.Data.ChatChannel; | ||
11154 | byte[] msg = rdialog.Data.ButtonLabel; | ||
11155 | if (OnChatFromClient != null) | ||
11156 | { | ||
11157 | OSChatMessage args = new OSChatMessage(); | ||
11158 | args.Channel = ch; | ||
11159 | args.From = String.Empty; | ||
11160 | args.Message = Utils.BytesToString(msg); | ||
11161 | args.Type = ChatTypeEnum.Shout; | ||
11162 | args.Position = new Vector3(); | ||
11163 | args.Scene = Scene; | ||
11164 | args.Sender = this; | ||
11165 | ChatMessage handlerChatFromClient2 = OnChatFromClient; | ||
11166 | if (handlerChatFromClient2 != null) | ||
11167 | handlerChatFromClient2(this, args); | ||
11168 | } | ||
11169 | |||
11170 | break; | ||
11171 | |||
11172 | case PacketType.ImprovedInstantMessage: | ||
11173 | ImprovedInstantMessagePacket msgpack = (ImprovedInstantMessagePacket)Pack; | ||
11174 | |||
11175 | #region Packet Session and User Check | ||
11176 | if (m_checkPackets) | ||
11177 | { | ||
11178 | if (msgpack.AgentData.SessionID != SessionId || | ||
11179 | msgpack.AgentData.AgentID != AgentId) | ||
11180 | break; | ||
11181 | } | ||
11182 | #endregion | ||
11183 | |||
11184 | string IMfromName = Util.FieldToString(msgpack.MessageBlock.FromAgentName); | ||
11185 | string IMmessage = Utils.BytesToString(msgpack.MessageBlock.Message); | ||
11186 | ImprovedInstantMessage handlerInstantMessage = OnInstantMessage; | ||
11187 | |||
11188 | if (handlerInstantMessage != null) | ||
11189 | { | ||
11190 | GridInstantMessage im = new GridInstantMessage(Scene, | ||
11191 | msgpack.AgentData.AgentID, | ||
11192 | IMfromName, | ||
11193 | msgpack.MessageBlock.ToAgentID, | ||
11194 | msgpack.MessageBlock.Dialog, | ||
11195 | msgpack.MessageBlock.FromGroup, | ||
11196 | IMmessage, | ||
11197 | msgpack.MessageBlock.ID, | ||
11198 | msgpack.MessageBlock.Offline != 0 ? true : false, | ||
11199 | msgpack.MessageBlock.Position, | ||
11200 | msgpack.MessageBlock.BinaryBucket); | ||
11201 | |||
11202 | handlerInstantMessage(this, im); | ||
11203 | } | ||
11204 | break; | ||
11205 | |||
11206 | case PacketType.AcceptFriendship: | ||
11207 | AcceptFriendshipPacket afriendpack = (AcceptFriendshipPacket)Pack; | ||
11208 | |||
11209 | #region Packet Session and User Check | ||
11210 | if (m_checkPackets) | ||
11211 | { | ||
11212 | if (afriendpack.AgentData.SessionID != SessionId || | ||
11213 | afriendpack.AgentData.AgentID != AgentId) | ||
11214 | break; | ||
11215 | } | ||
11216 | #endregion | ||
11217 | |||
11218 | // My guess is this is the folder to stick the calling card into | ||
11219 | List<UUID> callingCardFolders = new List<UUID>(); | ||
11220 | |||
11221 | UUID agentID = afriendpack.AgentData.AgentID; | ||
11222 | UUID transactionID = afriendpack.TransactionBlock.TransactionID; | ||
11223 | |||
11224 | for (int fi = 0; fi < afriendpack.FolderData.Length; fi++) | ||
11225 | { | ||
11226 | callingCardFolders.Add(afriendpack.FolderData[fi].FolderID); | ||
11227 | } | ||
11228 | |||
11229 | FriendActionDelegate handlerApproveFriendRequest = OnApproveFriendRequest; | ||
11230 | if (handlerApproveFriendRequest != null) | ||
11231 | { | ||
11232 | handlerApproveFriendRequest(this, agentID, transactionID, callingCardFolders); | ||
11233 | } | ||
11234 | break; | ||
11235 | |||
11236 | case PacketType.DeclineFriendship: | ||
11237 | DeclineFriendshipPacket dfriendpack = (DeclineFriendshipPacket)Pack; | ||
11238 | |||
11239 | #region Packet Session and User Check | ||
11240 | if (m_checkPackets) | ||
11241 | { | ||
11242 | if (dfriendpack.AgentData.SessionID != SessionId || | ||
11243 | dfriendpack.AgentData.AgentID != AgentId) | ||
11244 | break; | ||
11245 | } | ||
11246 | #endregion | ||
11247 | |||
11248 | if (OnDenyFriendRequest != null) | ||
11249 | { | ||
11250 | OnDenyFriendRequest(this, | ||
11251 | dfriendpack.AgentData.AgentID, | ||
11252 | dfriendpack.TransactionBlock.TransactionID, | ||
11253 | null); | ||
11254 | } | ||
11255 | break; | ||
11256 | |||
11257 | case PacketType.TerminateFriendship: | ||
11258 | TerminateFriendshipPacket tfriendpack = (TerminateFriendshipPacket)Pack; | ||
11259 | |||
11260 | #region Packet Session and User Check | ||
11261 | if (m_checkPackets) | ||
11262 | { | ||
11263 | if (tfriendpack.AgentData.SessionID != SessionId || | ||
11264 | tfriendpack.AgentData.AgentID != AgentId) | ||
11265 | break; | ||
11266 | } | ||
11267 | #endregion | ||
11268 | |||
11269 | UUID listOwnerAgentID = tfriendpack.AgentData.AgentID; | ||
11270 | UUID exFriendID = tfriendpack.ExBlock.OtherID; | ||
11271 | |||
11272 | FriendshipTermination handlerTerminateFriendship = OnTerminateFriendship; | ||
11273 | if (handlerTerminateFriendship != null) | ||
11274 | { | ||
11275 | handlerTerminateFriendship(this, listOwnerAgentID, exFriendID); | ||
11276 | } | ||
11277 | break; | ||
11278 | |||
11279 | case PacketType.RezObject: | ||
11280 | RezObjectPacket rezPacket = (RezObjectPacket)Pack; | ||
11281 | |||
11282 | #region Packet Session and User Check | ||
11283 | if (m_checkPackets) | ||
11284 | { | ||
11285 | if (rezPacket.AgentData.SessionID != SessionId || | ||
11286 | rezPacket.AgentData.AgentID != AgentId) | ||
11287 | break; | ||
11288 | } | ||
11289 | #endregion | ||
11290 | |||
11291 | RezObject handlerRezObject = OnRezObject; | ||
11292 | if (handlerRezObject != null) | ||
11293 | { | ||
11294 | handlerRezObject(this, rezPacket.InventoryData.ItemID, rezPacket.RezData.RayEnd, | ||
11295 | rezPacket.RezData.RayStart, rezPacket.RezData.RayTargetID, | ||
11296 | rezPacket.RezData.BypassRaycast, rezPacket.RezData.RayEndIsIntersection, | ||
11297 | rezPacket.RezData.RezSelected, rezPacket.RezData.RemoveItem, | ||
11298 | rezPacket.RezData.FromTaskID); | ||
11299 | } | ||
11300 | break; | ||
11301 | |||
11302 | case PacketType.DeRezObject: | ||
11303 | DeRezObjectPacket DeRezPacket = (DeRezObjectPacket)Pack; | ||
11304 | |||
11305 | #region Packet Session and User Check | ||
11306 | if (m_checkPackets) | ||
11307 | { | ||
11308 | if (DeRezPacket.AgentData.SessionID != SessionId || | ||
11309 | DeRezPacket.AgentData.AgentID != AgentId) | ||
11310 | break; | ||
11311 | } | ||
11312 | #endregion | ||
11313 | |||
11314 | DeRezObject handlerDeRezObject = OnDeRezObject; | ||
11315 | if (handlerDeRezObject != null) | ||
11316 | { | ||
11317 | List<uint> deRezIDs = new List<uint>(); | ||
11318 | |||
11319 | foreach (DeRezObjectPacket.ObjectDataBlock data in | ||
11320 | DeRezPacket.ObjectData) | ||
11321 | { | ||
11322 | deRezIDs.Add(data.ObjectLocalID); | ||
11323 | } | ||
11324 | // It just so happens that the values on the DeRezAction enumerator match the Destination | ||
11325 | // values given by a Second Life client | ||
11326 | handlerDeRezObject(this, deRezIDs, | ||
11327 | DeRezPacket.AgentBlock.GroupID, | ||
11328 | (DeRezAction)DeRezPacket.AgentBlock.Destination, | ||
11329 | DeRezPacket.AgentBlock.DestinationID); | ||
11330 | |||
11331 | } | ||
11332 | break; | ||
11333 | |||
11334 | case PacketType.ModifyLand: | ||
11335 | ModifyLandPacket modify = (ModifyLandPacket)Pack; | ||
11336 | |||
11337 | #region Packet Session and User Check | ||
11338 | if (m_checkPackets) | ||
11339 | { | ||
11340 | if (modify.AgentData.SessionID != SessionId || | ||
11341 | modify.AgentData.AgentID != AgentId) | ||
11342 | break; | ||
11343 | } | ||
11344 | |||
11345 | #endregion | ||
11346 | //m_log.Info("[LAND]: LAND:" + modify.ToString()); | ||
11347 | if (modify.ParcelData.Length > 0) | ||
11348 | { | ||
11349 | if (OnModifyTerrain != null) | ||
11350 | { | ||
11351 | for (int i = 0; i < modify.ParcelData.Length; i++) | ||
11352 | { | ||
11353 | ModifyTerrain handlerModifyTerrain = OnModifyTerrain; | ||
11354 | if (handlerModifyTerrain != null) | ||
11355 | { | ||
11356 | handlerModifyTerrain(AgentId, modify.ModifyBlock.Height, modify.ModifyBlock.Seconds, | ||
11357 | modify.ModifyBlock.BrushSize, | ||
11358 | modify.ModifyBlock.Action, modify.ParcelData[i].North, | ||
11359 | modify.ParcelData[i].West, modify.ParcelData[i].South, | ||
11360 | modify.ParcelData[i].East, AgentId); | ||
11361 | } | ||
11362 | } | ||
11363 | } | ||
11364 | } | ||
11365 | |||
11366 | break; | ||
11367 | |||
11368 | case PacketType.RegionHandshakeReply: | ||
11369 | |||
11370 | Action<IClientAPI> handlerRegionHandShakeReply = OnRegionHandShakeReply; | ||
11371 | if (handlerRegionHandShakeReply != null) | ||
11372 | { | ||
11373 | handlerRegionHandShakeReply(this); | ||
11374 | } | ||
11375 | |||
11376 | break; | ||
11377 | |||
11378 | case PacketType.AgentWearablesRequest: | ||
11379 | GenericCall2 handlerRequestWearables = OnRequestWearables; | ||
11380 | |||
11381 | if (handlerRequestWearables != null) | ||
11382 | { | ||
11383 | handlerRequestWearables(); | ||
11384 | } | ||
11385 | |||
11386 | Action<IClientAPI> handlerRequestAvatarsData = OnRequestAvatarsData; | ||
11387 | |||
11388 | if (handlerRequestAvatarsData != null) | ||
11389 | { | ||
11390 | handlerRequestAvatarsData(this); | ||
11391 | } | ||
11392 | |||
11393 | break; | ||
11394 | |||
11395 | case PacketType.AgentSetAppearance: | ||
11396 | AgentSetAppearancePacket appear = (AgentSetAppearancePacket)Pack; | ||
11397 | |||
11398 | #region Packet Session and User Check | ||
11399 | if (m_checkPackets) | ||
11400 | { | ||
11401 | if (appear.AgentData.SessionID != SessionId || | ||
11402 | appear.AgentData.AgentID != AgentId) | ||
11403 | break; | ||
11404 | } | ||
11405 | #endregion | ||
11406 | |||
11407 | SetAppearance handlerSetAppearance = OnSetAppearance; | ||
11408 | if (handlerSetAppearance != null) | ||
11409 | { | ||
11410 | // Temporarily protect ourselves from the mantis #951 failure. | ||
11411 | // However, we could do this for several other handlers where a failure isn't terminal | ||
11412 | // for the client session anyway, in order to protect ourselves against bad code in plugins | ||
11413 | try | ||
11414 | { | ||
11415 | byte[] visualparams = new byte[appear.VisualParam.Length]; | ||
11416 | for (int i = 0; i < appear.VisualParam.Length; i++) | ||
11417 | visualparams[i] = appear.VisualParam[i].ParamValue; | ||
11418 | |||
11419 | Primitive.TextureEntry te = null; | ||
11420 | if (appear.ObjectData.TextureEntry.Length > 1) | ||
11421 | te = new Primitive.TextureEntry(appear.ObjectData.TextureEntry, 0, appear.ObjectData.TextureEntry.Length); | ||
11422 | |||
11423 | handlerSetAppearance(te, visualparams); | ||
11424 | } | ||
11425 | catch (Exception e) | ||
11426 | { | ||
11427 | m_log.ErrorFormat( | ||
11428 | "[CLIENT VIEW]: AgentSetApperance packet handler threw an exception, {0}", | ||
11429 | e); | ||
11430 | } | ||
11431 | } | ||
11432 | |||
11433 | break; | ||
11434 | |||
11435 | case PacketType.AgentIsNowWearing: | ||
11436 | if (OnAvatarNowWearing != null) | ||
11437 | { | ||
11438 | AgentIsNowWearingPacket nowWearing = (AgentIsNowWearingPacket)Pack; | ||
11439 | |||
11440 | #region Packet Session and User Check | ||
11441 | if (m_checkPackets) | ||
11442 | { | ||
11443 | if (nowWearing.AgentData.SessionID != SessionId || | ||
11444 | nowWearing.AgentData.AgentID != AgentId) | ||
11445 | break; | ||
11446 | } | ||
11447 | #endregion | ||
11448 | |||
11449 | AvatarWearingArgs wearingArgs = new AvatarWearingArgs(); | ||
11450 | for (int i = 0; i < nowWearing.WearableData.Length; i++) | ||
11451 | { | ||
11452 | AvatarWearingArgs.Wearable wearable = | ||
11453 | new AvatarWearingArgs.Wearable(nowWearing.WearableData[i].ItemID, | ||
11454 | nowWearing.WearableData[i].WearableType); | ||
11455 | wearingArgs.NowWearing.Add(wearable); | ||
11456 | } | ||
11457 | |||
11458 | AvatarNowWearing handlerAvatarNowWearing = OnAvatarNowWearing; | ||
11459 | if (handlerAvatarNowWearing != null) | ||
11460 | { | ||
11461 | handlerAvatarNowWearing(this, wearingArgs); | ||
11462 | } | ||
11463 | } | ||
11464 | break; | ||
11465 | |||
11466 | case PacketType.RezSingleAttachmentFromInv: | ||
11467 | RezSingleAttachmentFromInv handlerRezSingleAttachment = OnRezSingleAttachmentFromInv; | ||
11468 | if (handlerRezSingleAttachment != null) | ||
11469 | { | ||
11470 | RezSingleAttachmentFromInvPacket rez = (RezSingleAttachmentFromInvPacket)Pack; | ||
11471 | |||
11472 | #region Packet Session and User Check | ||
11473 | if (m_checkPackets) | ||
11474 | { | ||
11475 | if (rez.AgentData.SessionID != SessionId || | ||
11476 | rez.AgentData.AgentID != AgentId) | ||
11477 | break; | ||
11478 | } | ||
11479 | #endregion | ||
11480 | |||
11481 | handlerRezSingleAttachment(this, rez.ObjectData.ItemID, | ||
11482 | rez.ObjectData.AttachmentPt); | ||
11483 | } | ||
11484 | |||
11485 | break; | ||
11486 | |||
11487 | case PacketType.RezMultipleAttachmentsFromInv: | ||
11488 | RezMultipleAttachmentsFromInv handlerRezMultipleAttachments = OnRezMultipleAttachmentsFromInv; | ||
11489 | if (handlerRezMultipleAttachments != null) | ||
11490 | { | ||
11491 | RezMultipleAttachmentsFromInvPacket rez = (RezMultipleAttachmentsFromInvPacket)Pack; | ||
11492 | handlerRezMultipleAttachments(this, rez.HeaderData, | ||
11493 | rez.ObjectData); | ||
11494 | } | ||
11495 | |||
11496 | break; | ||
11497 | |||
11498 | case PacketType.DetachAttachmentIntoInv: | ||
11499 | UUIDNameRequest handlerDetachAttachmentIntoInv = OnDetachAttachmentIntoInv; | ||
11500 | if (handlerDetachAttachmentIntoInv != null) | ||
11501 | { | ||
11502 | DetachAttachmentIntoInvPacket detachtoInv = (DetachAttachmentIntoInvPacket)Pack; | ||
11503 | |||
11504 | #region Packet Session and User Check | ||
11505 | // UNSUPPORTED ON THIS PACKET | ||
11506 | #endregion | ||
11507 | |||
11508 | UUID itemID = detachtoInv.ObjectData.ItemID; | ||
11509 | // UUID ATTACH_agentID = detachtoInv.ObjectData.AgentID; | ||
11510 | |||
11511 | handlerDetachAttachmentIntoInv(itemID, this); | ||
11512 | } | ||
11513 | break; | ||
11514 | |||
11515 | case PacketType.ObjectAttach: | ||
11516 | if (OnObjectAttach != null) | ||
11517 | { | ||
11518 | ObjectAttachPacket att = (ObjectAttachPacket)Pack; | ||
11519 | |||
11520 | #region Packet Session and User Check | ||
11521 | if (m_checkPackets) | ||
11522 | { | ||
11523 | if (att.AgentData.SessionID != SessionId || | ||
11524 | att.AgentData.AgentID != AgentId) | ||
11525 | break; | ||
11526 | } | ||
11527 | #endregion | ||
11528 | |||
11529 | ObjectAttach handlerObjectAttach = OnObjectAttach; | ||
11530 | |||
11531 | if (handlerObjectAttach != null) | ||
11532 | { | ||
11533 | if (att.ObjectData.Length > 0) | ||
11534 | { | ||
11535 | handlerObjectAttach(this, att.ObjectData[0].ObjectLocalID, att.AgentData.AttachmentPoint, att.ObjectData[0].Rotation, false); | ||
11536 | } | ||
11537 | } | ||
11538 | } | ||
11539 | break; | ||
11540 | |||
11541 | case PacketType.ObjectDetach: | ||
11542 | ObjectDetachPacket dett = (ObjectDetachPacket)Pack; | ||
11543 | |||
11544 | #region Packet Session and User Check | ||
11545 | if (m_checkPackets) | ||
11546 | { | ||
11547 | if (dett.AgentData.SessionID != SessionId || | ||
11548 | dett.AgentData.AgentID != AgentId) | ||
11549 | break; | ||
11550 | } | ||
11551 | #endregion | ||
11552 | |||
11553 | for (int j = 0; j < dett.ObjectData.Length; j++) | ||
11554 | { | ||
11555 | uint obj = dett.ObjectData[j].ObjectLocalID; | ||
11556 | ObjectDeselect handlerObjectDetach = OnObjectDetach; | ||
11557 | if (handlerObjectDetach != null) | ||
11558 | { | ||
11559 | handlerObjectDetach(obj, this); | ||
11560 | } | ||
11561 | |||
11562 | } | ||
11563 | break; | ||
11564 | |||
11565 | case PacketType.ObjectDrop: | ||
11566 | ObjectDropPacket dropp = (ObjectDropPacket)Pack; | ||
11567 | |||
11568 | #region Packet Session and User Check | ||
11569 | if (m_checkPackets) | ||
11570 | { | ||
11571 | if (dropp.AgentData.SessionID != SessionId || | ||
11572 | dropp.AgentData.AgentID != AgentId) | ||
11573 | break; | ||
11574 | } | ||
11575 | #endregion | ||
11576 | |||
11577 | for (int j = 0; j < dropp.ObjectData.Length; j++) | ||
11578 | { | ||
11579 | uint obj = dropp.ObjectData[j].ObjectLocalID; | ||
11580 | ObjectDrop handlerObjectDrop = OnObjectDrop; | ||
11581 | if (handlerObjectDrop != null) | ||
11582 | { | ||
11583 | handlerObjectDrop(obj, this); | ||
11584 | } | ||
11585 | } | ||
11586 | break; | ||
11587 | |||
11588 | case PacketType.SetAlwaysRun: | ||
11589 | SetAlwaysRunPacket run = (SetAlwaysRunPacket)Pack; | ||
11590 | |||
11591 | #region Packet Session and User Check | ||
11592 | if (m_checkPackets) | ||
11593 | { | ||
11594 | if (run.AgentData.SessionID != SessionId || | ||
11595 | run.AgentData.AgentID != AgentId) | ||
11596 | break; | ||
11597 | } | ||
11598 | #endregion | ||
11599 | |||
11600 | SetAlwaysRun handlerSetAlwaysRun = OnSetAlwaysRun; | ||
11601 | if (handlerSetAlwaysRun != null) | ||
11602 | handlerSetAlwaysRun(this, run.AgentData.AlwaysRun); | ||
11603 | |||
11604 | break; | ||
11605 | |||
11606 | case PacketType.CompleteAgentMovement: | ||
11607 | GenericCall2 handlerCompleteMovementToRegion = OnCompleteMovementToRegion; | ||
11608 | if (handlerCompleteMovementToRegion != null) | ||
11609 | { | ||
11610 | handlerCompleteMovementToRegion(); | ||
11611 | } | ||
11612 | handlerCompleteMovementToRegion = null; | ||
11613 | |||
11614 | break; | ||
11615 | |||
11616 | case PacketType.AgentAnimation: | ||
11617 | AgentAnimationPacket AgentAni = (AgentAnimationPacket)Pack; | ||
11618 | |||
11619 | #region Packet Session and User Check | ||
11620 | if (m_checkPackets) | ||
11621 | { | ||
11622 | if (AgentAni.AgentData.SessionID != SessionId || | ||
11623 | AgentAni.AgentData.AgentID != AgentId) | ||
11624 | break; | ||
11625 | } | ||
11626 | #endregion | ||
11627 | |||
11628 | StartAnim handlerStartAnim = null; | ||
11629 | StopAnim handlerStopAnim = null; | ||
11630 | |||
11631 | for (int i = 0; i < AgentAni.AnimationList.Length; i++) | ||
11632 | { | ||
11633 | if (AgentAni.AnimationList[i].StartAnim) | ||
11634 | { | ||
11635 | handlerStartAnim = OnStartAnim; | ||
11636 | if (handlerStartAnim != null) | ||
11637 | { | ||
11638 | handlerStartAnim(this, AgentAni.AnimationList[i].AnimID); | ||
11639 | } | ||
11640 | } | ||
11641 | else | ||
11642 | { | ||
11643 | handlerStopAnim = OnStopAnim; | ||
11644 | if (handlerStopAnim != null) | ||
11645 | { | ||
11646 | handlerStopAnim(this, AgentAni.AnimationList[i].AnimID); | ||
11647 | } | ||
11648 | } | ||
11649 | } | ||
11650 | break; | ||
11651 | |||
11652 | case PacketType.AgentRequestSit: | ||
11653 | if (OnAgentRequestSit != null) | ||
11654 | { | ||
11655 | AgentRequestSitPacket agentRequestSit = (AgentRequestSitPacket)Pack; | ||
11656 | |||
11657 | #region Packet Session and User Check | ||
11658 | if (m_checkPackets) | ||
11659 | { | ||
11660 | if (agentRequestSit.AgentData.SessionID != SessionId || | ||
11661 | agentRequestSit.AgentData.AgentID != AgentId) | ||
11662 | break; | ||
11663 | } | ||
11664 | #endregion | ||
11665 | |||
11666 | AgentRequestSit handlerAgentRequestSit = OnAgentRequestSit; | ||
11667 | if (handlerAgentRequestSit != null) | ||
11668 | handlerAgentRequestSit(this, agentRequestSit.AgentData.AgentID, | ||
11669 | agentRequestSit.TargetObject.TargetID, agentRequestSit.TargetObject.Offset); | ||
11670 | } | ||
11671 | break; | ||
11672 | |||
11673 | case PacketType.AgentSit: | ||
11674 | if (OnAgentSit != null) | ||
11675 | { | ||
11676 | AgentSitPacket agentSit = (AgentSitPacket)Pack; | ||
11677 | |||
11678 | #region Packet Session and User Check | ||
11679 | if (m_checkPackets) | ||
11680 | { | ||
11681 | if (agentSit.AgentData.SessionID != SessionId || | ||
11682 | agentSit.AgentData.AgentID != AgentId) | ||
11683 | break; | ||
11684 | } | ||
11685 | #endregion | ||
11686 | |||
11687 | AgentSit handlerAgentSit = OnAgentSit; | ||
11688 | if (handlerAgentSit != null) | ||
11689 | { | ||
11690 | OnAgentSit(this, agentSit.AgentData.AgentID); | ||
11691 | } | ||
11692 | } | ||
11693 | break; | ||
11694 | |||
11695 | case PacketType.SoundTrigger: | ||
11696 | SoundTriggerPacket soundTriggerPacket = (SoundTriggerPacket)Pack; | ||
11697 | |||
11698 | #region Packet Session and User Check | ||
11699 | if (m_checkPackets) | ||
11700 | { | ||
11701 | // UNSUPPORTED ON THIS PACKET | ||
11702 | } | ||
11703 | #endregion | ||
11704 | |||
11705 | SoundTrigger handlerSoundTrigger = OnSoundTrigger; | ||
11706 | if (handlerSoundTrigger != null) | ||
11707 | { | ||
11708 | handlerSoundTrigger(soundTriggerPacket.SoundData.SoundID, soundTriggerPacket.SoundData.OwnerID, | ||
11709 | soundTriggerPacket.SoundData.ObjectID, soundTriggerPacket.SoundData.ParentID, | ||
11710 | soundTriggerPacket.SoundData.Gain, soundTriggerPacket.SoundData.Position, | ||
11711 | soundTriggerPacket.SoundData.Handle); | ||
11712 | |||
11713 | } | ||
11714 | break; | ||
11715 | |||
11716 | case PacketType.AvatarPickerRequest: | ||
11717 | AvatarPickerRequestPacket avRequestQuery = (AvatarPickerRequestPacket)Pack; | ||
11718 | |||
11719 | #region Packet Session and User Check | ||
11720 | if (m_checkPackets) | ||
11721 | { | ||
11722 | if (avRequestQuery.AgentData.SessionID != SessionId || | ||
11723 | avRequestQuery.AgentData.AgentID != AgentId) | ||
11724 | break; | ||
11725 | } | ||
11726 | #endregion | ||
11727 | |||
11728 | AvatarPickerRequestPacket.AgentDataBlock Requestdata = avRequestQuery.AgentData; | ||
11729 | AvatarPickerRequestPacket.DataBlock querydata = avRequestQuery.Data; | ||
11730 | //m_log.Debug("Agent Sends:" + Utils.BytesToString(querydata.Name)); | ||
11731 | |||
11732 | AvatarPickerRequest handlerAvatarPickerRequest = OnAvatarPickerRequest; | ||
11733 | if (handlerAvatarPickerRequest != null) | ||
11734 | { | ||
11735 | handlerAvatarPickerRequest(this, Requestdata.AgentID, Requestdata.QueryID, | ||
11736 | Utils.BytesToString(querydata.Name)); | ||
11737 | } | ||
11738 | break; | ||
11739 | |||
11740 | case PacketType.AgentDataUpdateRequest: | ||
11741 | AgentDataUpdateRequestPacket avRequestDataUpdatePacket = (AgentDataUpdateRequestPacket)Pack; | ||
11742 | |||
11743 | #region Packet Session and User Check | ||
11744 | if (m_checkPackets) | ||
11745 | { | ||
11746 | if (avRequestDataUpdatePacket.AgentData.SessionID != SessionId || | ||
11747 | avRequestDataUpdatePacket.AgentData.AgentID != AgentId) | ||
11748 | break; | ||
11749 | } | ||
11750 | #endregion | ||
11751 | |||
11752 | FetchInventory handlerAgentDataUpdateRequest = OnAgentDataUpdateRequest; | ||
11753 | |||
11754 | if (handlerAgentDataUpdateRequest != null) | ||
11755 | { | ||
11756 | handlerAgentDataUpdateRequest(this, avRequestDataUpdatePacket.AgentData.AgentID, avRequestDataUpdatePacket.AgentData.SessionID); | ||
11757 | } | ||
11758 | |||
11759 | break; | ||
11760 | |||
11761 | case PacketType.UserInfoRequest: | ||
11762 | UserInfoRequest handlerUserInfoRequest = OnUserInfoRequest; | ||
11763 | if (handlerUserInfoRequest != null) | ||
11764 | { | ||
11765 | handlerUserInfoRequest(this); | ||
11766 | } | ||
11767 | else | ||
11768 | { | ||
11769 | SendUserInfoReply(false, true, ""); | ||
11770 | } | ||
11771 | break; | ||
11772 | |||
11773 | case PacketType.UpdateUserInfo: | ||
11774 | UpdateUserInfoPacket updateUserInfo = (UpdateUserInfoPacket)Pack; | ||
11775 | |||
11776 | #region Packet Session and User Check | ||
11777 | if (m_checkPackets) | ||
11778 | { | ||
11779 | if (updateUserInfo.AgentData.SessionID != SessionId || | ||
11780 | updateUserInfo.AgentData.AgentID != AgentId) | ||
11781 | break; | ||
11782 | } | ||
11783 | #endregion | ||
11784 | |||
11785 | UpdateUserInfo handlerUpdateUserInfo = OnUpdateUserInfo; | ||
11786 | if (handlerUpdateUserInfo != null) | ||
11787 | { | ||
11788 | bool visible = true; | ||
11789 | string DirectoryVisibility = | ||
11790 | Utils.BytesToString(updateUserInfo.UserData.DirectoryVisibility); | ||
11791 | if (DirectoryVisibility == "hidden") | ||
11792 | visible = false; | ||
11793 | |||
11794 | handlerUpdateUserInfo( | ||
11795 | updateUserInfo.UserData.IMViaEMail, | ||
11796 | visible, this); | ||
11797 | } | ||
11798 | break; | ||
11799 | |||
11800 | case PacketType.SetStartLocationRequest: | ||
11801 | SetStartLocationRequestPacket avSetStartLocationRequestPacket = (SetStartLocationRequestPacket)Pack; | ||
11802 | |||
11803 | #region Packet Session and User Check | ||
11804 | if (m_checkPackets) | ||
11805 | { | ||
11806 | if (avSetStartLocationRequestPacket.AgentData.SessionID != SessionId || | ||
11807 | avSetStartLocationRequestPacket.AgentData.AgentID != AgentId) | ||
11808 | break; | ||
11809 | } | ||
11810 | #endregion | ||
11811 | |||
11812 | if (avSetStartLocationRequestPacket.AgentData.AgentID == AgentId && avSetStartLocationRequestPacket.AgentData.SessionID == SessionId) | ||
11813 | { | ||
11814 | TeleportLocationRequest handlerSetStartLocationRequest = OnSetStartLocationRequest; | ||
11815 | if (handlerSetStartLocationRequest != null) | ||
11816 | { | ||
11817 | handlerSetStartLocationRequest(this, 0, avSetStartLocationRequestPacket.StartLocationData.LocationPos, | ||
11818 | avSetStartLocationRequestPacket.StartLocationData.LocationLookAt, | ||
11819 | avSetStartLocationRequestPacket.StartLocationData.LocationID); | ||
11820 | } | ||
11821 | } | ||
11822 | break; | ||
11823 | |||
11824 | case PacketType.AgentThrottle: | ||
11825 | AgentThrottlePacket atpack = (AgentThrottlePacket)Pack; | ||
11826 | |||
11827 | #region Packet Session and User Check | ||
11828 | if (m_checkPackets) | ||
11829 | { | ||
11830 | if (atpack.AgentData.SessionID != SessionId || | ||
11831 | atpack.AgentData.AgentID != AgentId) | ||
11832 | break; | ||
11833 | } | ||
11834 | #endregion | ||
11835 | |||
11836 | m_udpClient.SetThrottles(atpack.Throttle.Throttles); | ||
11837 | break; | ||
11838 | |||
11839 | case PacketType.AgentPause: | ||
11840 | m_udpClient.IsPaused = true; | ||
11841 | break; | ||
11842 | |||
11843 | case PacketType.AgentResume: | ||
11844 | m_udpClient.IsPaused = false; | ||
11845 | SendStartPingCheck(m_udpClient.CurrentPingSequence++); | ||
11846 | |||
11847 | break; | ||
11848 | |||
11849 | case PacketType.ForceScriptControlRelease: | ||
11850 | ForceReleaseControls handlerForceReleaseControls = OnForceReleaseControls; | ||
11851 | if (handlerForceReleaseControls != null) | ||
11852 | { | ||
11853 | handlerForceReleaseControls(this, AgentId); | ||
11854 | } | ||
11855 | break; | ||
11856 | |||
11857 | #endregion | ||
11858 | |||
11859 | |||
11860 | //#region Objects/m_sceneObjects | ||
11861 | |||
11862 | case PacketType.ObjectLink: | ||
11863 | ObjectLinkPacket link = (ObjectLinkPacket)Pack; | ||
11864 | |||
11865 | #region Packet Session and User Check | ||
11866 | if (m_checkPackets) | ||
11867 | { | ||
11868 | if (link.AgentData.SessionID != SessionId || | ||
11869 | link.AgentData.AgentID != AgentId) | ||
11870 | break; | ||
11871 | } | ||
11872 | #endregion | ||
11873 | |||
11874 | uint parentprimid = 0; | ||
11875 | List<uint> childrenprims = new List<uint>(); | ||
11876 | if (link.ObjectData.Length > 1) | ||
11877 | { | ||
11878 | parentprimid = link.ObjectData[0].ObjectLocalID; | ||
11879 | |||
11880 | for (int i = 1; i < link.ObjectData.Length; i++) | ||
11881 | { | ||
11882 | childrenprims.Add(link.ObjectData[i].ObjectLocalID); | ||
11883 | } | ||
11884 | } | ||
11885 | LinkObjects handlerLinkObjects = OnLinkObjects; | ||
11886 | if (handlerLinkObjects != null) | ||
11887 | { | ||
11888 | handlerLinkObjects(this, parentprimid, childrenprims); | ||
11889 | } | ||
11890 | break; | ||
11891 | |||
11892 | case PacketType.ObjectDelink: | ||
11893 | ObjectDelinkPacket delink = (ObjectDelinkPacket)Pack; | ||
11894 | |||
11895 | #region Packet Session and User Check | ||
11896 | if (m_checkPackets) | ||
11897 | { | ||
11898 | if (delink.AgentData.SessionID != SessionId || | ||
11899 | delink.AgentData.AgentID != AgentId) | ||
11900 | break; | ||
11901 | } | ||
11902 | #endregion | ||
11903 | |||
11904 | // It appears the prim at index 0 is not always the root prim (for | ||
11905 | // instance, when one prim of a link set has been edited independently | ||
11906 | // of the others). Therefore, we'll pass all the ids onto the delink | ||
11907 | // method for it to decide which is the root. | ||
11908 | List<uint> prims = new List<uint>(); | ||
11909 | for (int i = 0; i < delink.ObjectData.Length; i++) | ||
11910 | { | ||
11911 | prims.Add(delink.ObjectData[i].ObjectLocalID); | ||
11912 | } | ||
11913 | DelinkObjects handlerDelinkObjects = OnDelinkObjects; | ||
11914 | if (handlerDelinkObjects != null) | ||
11915 | { | ||
11916 | handlerDelinkObjects(prims); | ||
11917 | } | ||
11918 | |||
11919 | break; | ||
11920 | |||
11921 | case PacketType.ObjectAdd: | ||
11922 | if (OnAddPrim != null) | ||
11923 | { | ||
11924 | ObjectAddPacket addPacket = (ObjectAddPacket)Pack; | ||
11925 | |||
11926 | #region Packet Session and User Check | ||
11927 | if (m_checkPackets) | ||
11928 | { | ||
11929 | if (addPacket.AgentData.SessionID != SessionId || | ||
11930 | addPacket.AgentData.AgentID != AgentId) | ||
11931 | break; | ||
11932 | } | ||
11933 | #endregion | ||
11934 | |||
11935 | PrimitiveBaseShape shape = GetShapeFromAddPacket(addPacket); | ||
11936 | // m_log.Info("[REZData]: " + addPacket.ToString()); | ||
11937 | //BypassRaycast: 1 | ||
11938 | //RayStart: <69.79469, 158.2652, 98.40343> | ||
11939 | //RayEnd: <61.97724, 141.995, 92.58341> | ||
11940 | //RayTargetID: 00000000-0000-0000-0000-000000000000 | ||
11941 | |||
11942 | //Check to see if adding the prim is allowed; useful for any module wanting to restrict the | ||
11943 | //object from rezing initially | ||
11944 | |||
11945 | AddNewPrim handlerAddPrim = OnAddPrim; | ||
11946 | if (handlerAddPrim != null) | ||
11947 | handlerAddPrim(AgentId, ActiveGroupId, addPacket.ObjectData.RayEnd, addPacket.ObjectData.Rotation, shape, addPacket.ObjectData.BypassRaycast, addPacket.ObjectData.RayStart, addPacket.ObjectData.RayTargetID, addPacket.ObjectData.RayEndIsIntersection); | ||
11948 | } | ||
11949 | break; | ||
11950 | |||
11951 | case PacketType.ObjectShape: | ||
11952 | ObjectShapePacket shapePacket = (ObjectShapePacket)Pack; | ||
11953 | |||
11954 | #region Packet Session and User Check | ||
11955 | if (m_checkPackets) | ||
11956 | { | ||
11957 | if (shapePacket.AgentData.SessionID != SessionId || | ||
11958 | shapePacket.AgentData.AgentID != AgentId) | ||
11959 | break; | ||
11960 | } | ||
11961 | #endregion | ||
11962 | |||
11963 | UpdateShape handlerUpdatePrimShape = null; | ||
11964 | for (int i = 0; i < shapePacket.ObjectData.Length; i++) | ||
11965 | { | ||
11966 | handlerUpdatePrimShape = OnUpdatePrimShape; | ||
11967 | if (handlerUpdatePrimShape != null) | ||
11968 | { | ||
11969 | UpdateShapeArgs shapeData = new UpdateShapeArgs(); | ||
11970 | shapeData.ObjectLocalID = shapePacket.ObjectData[i].ObjectLocalID; | ||
11971 | shapeData.PathBegin = shapePacket.ObjectData[i].PathBegin; | ||
11972 | shapeData.PathCurve = shapePacket.ObjectData[i].PathCurve; | ||
11973 | shapeData.PathEnd = shapePacket.ObjectData[i].PathEnd; | ||
11974 | shapeData.PathRadiusOffset = shapePacket.ObjectData[i].PathRadiusOffset; | ||
11975 | shapeData.PathRevolutions = shapePacket.ObjectData[i].PathRevolutions; | ||
11976 | shapeData.PathScaleX = shapePacket.ObjectData[i].PathScaleX; | ||
11977 | shapeData.PathScaleY = shapePacket.ObjectData[i].PathScaleY; | ||
11978 | shapeData.PathShearX = shapePacket.ObjectData[i].PathShearX; | ||
11979 | shapeData.PathShearY = shapePacket.ObjectData[i].PathShearY; | ||
11980 | shapeData.PathSkew = shapePacket.ObjectData[i].PathSkew; | ||
11981 | shapeData.PathTaperX = shapePacket.ObjectData[i].PathTaperX; | ||
11982 | shapeData.PathTaperY = shapePacket.ObjectData[i].PathTaperY; | ||
11983 | shapeData.PathTwist = shapePacket.ObjectData[i].PathTwist; | ||
11984 | shapeData.PathTwistBegin = shapePacket.ObjectData[i].PathTwistBegin; | ||
11985 | shapeData.ProfileBegin = shapePacket.ObjectData[i].ProfileBegin; | ||
11986 | shapeData.ProfileCurve = shapePacket.ObjectData[i].ProfileCurve; | ||
11987 | shapeData.ProfileEnd = shapePacket.ObjectData[i].ProfileEnd; | ||
11988 | shapeData.ProfileHollow = shapePacket.ObjectData[i].ProfileHollow; | ||
11989 | |||
11990 | handlerUpdatePrimShape(m_agentId, shapePacket.ObjectData[i].ObjectLocalID, | ||
11991 | shapeData); | ||
11992 | } | ||
11993 | } | ||
11994 | break; | ||
11995 | |||
11996 | case PacketType.ObjectExtraParams: | ||
11997 | ObjectExtraParamsPacket extraPar = (ObjectExtraParamsPacket)Pack; | ||
11998 | |||
11999 | #region Packet Session and User Check | ||
12000 | if (m_checkPackets) | ||
12001 | { | ||
12002 | if (extraPar.AgentData.SessionID != SessionId || | ||
12003 | extraPar.AgentData.AgentID != AgentId) | ||
12004 | break; | ||
12005 | } | ||
12006 | #endregion | ||
12007 | |||
12008 | ObjectExtraParams handlerUpdateExtraParams = OnUpdateExtraParams; | ||
12009 | if (handlerUpdateExtraParams != null) | ||
12010 | { | ||
12011 | for (int i = 0; i < extraPar.ObjectData.Length; i++) | ||
12012 | { | ||
12013 | handlerUpdateExtraParams(m_agentId, extraPar.ObjectData[i].ObjectLocalID, | ||
12014 | extraPar.ObjectData[i].ParamType, | ||
12015 | extraPar.ObjectData[i].ParamInUse, extraPar.ObjectData[i].ParamData); | ||
12016 | } | ||
12017 | } | ||
12018 | break; | ||
12019 | |||
12020 | case PacketType.ObjectDuplicate: | ||
12021 | ObjectDuplicatePacket dupe = (ObjectDuplicatePacket)Pack; | ||
12022 | |||
12023 | #region Packet Session and User Check | ||
12024 | if (m_checkPackets) | ||
12025 | { | ||
12026 | if (dupe.AgentData.SessionID != SessionId || | ||
12027 | dupe.AgentData.AgentID != AgentId) | ||
12028 | break; | ||
12029 | } | ||
12030 | #endregion | ||
12031 | |||
12032 | ObjectDuplicatePacket.AgentDataBlock AgentandGroupData = dupe.AgentData; | ||
12033 | |||
12034 | ObjectDuplicate handlerObjectDuplicate = null; | ||
12035 | |||
12036 | for (int i = 0; i < dupe.ObjectData.Length; i++) | ||
12037 | { | ||
12038 | handlerObjectDuplicate = OnObjectDuplicate; | ||
12039 | if (handlerObjectDuplicate != null) | ||
12040 | { | ||
12041 | handlerObjectDuplicate(dupe.ObjectData[i].ObjectLocalID, dupe.SharedData.Offset, | ||
12042 | dupe.SharedData.DuplicateFlags, AgentandGroupData.AgentID, | ||
12043 | AgentandGroupData.GroupID); | ||
12044 | } | ||
12045 | } | ||
12046 | |||
12047 | break; | ||
12048 | |||
12049 | case PacketType.RequestMultipleObjects: | ||
12050 | RequestMultipleObjectsPacket incomingRequest = (RequestMultipleObjectsPacket)Pack; | ||
12051 | |||
12052 | #region Packet Session and User Check | ||
12053 | if (m_checkPackets) | ||
12054 | { | ||
12055 | if (incomingRequest.AgentData.SessionID != SessionId || | ||
12056 | incomingRequest.AgentData.AgentID != AgentId) | ||
12057 | break; | ||
12058 | } | ||
12059 | #endregion | ||
12060 | |||
12061 | ObjectRequest handlerObjectRequest = null; | ||
12062 | |||
12063 | for (int i = 0; i < incomingRequest.ObjectData.Length; i++) | ||
12064 | { | ||
12065 | handlerObjectRequest = OnObjectRequest; | ||
12066 | if (handlerObjectRequest != null) | ||
12067 | { | ||
12068 | handlerObjectRequest(incomingRequest.ObjectData[i].ID, this); | ||
12069 | } | ||
12070 | } | ||
12071 | break; | ||
12072 | |||
12073 | case PacketType.ObjectSelect: | ||
12074 | ObjectSelectPacket incomingselect = (ObjectSelectPacket)Pack; | ||
12075 | |||
12076 | #region Packet Session and User Check | ||
12077 | if (m_checkPackets) | ||
12078 | { | ||
12079 | if (incomingselect.AgentData.SessionID != SessionId || | ||
12080 | incomingselect.AgentData.AgentID != AgentId) | ||
12081 | break; | ||
12082 | } | ||
12083 | #endregion | ||
12084 | |||
12085 | ObjectSelect handlerObjectSelect = null; | ||
12086 | |||
12087 | for (int i = 0; i < incomingselect.ObjectData.Length; i++) | ||
12088 | { | ||
12089 | handlerObjectSelect = OnObjectSelect; | ||
12090 | if (handlerObjectSelect != null) | ||
12091 | { | ||
12092 | handlerObjectSelect(incomingselect.ObjectData[i].ObjectLocalID, this); | ||
12093 | } | ||
12094 | } | ||
12095 | break; | ||
12096 | |||
12097 | case PacketType.ObjectDeselect: | ||
12098 | ObjectDeselectPacket incomingdeselect = (ObjectDeselectPacket)Pack; | ||
12099 | |||
12100 | #region Packet Session and User Check | ||
12101 | if (m_checkPackets) | ||
12102 | { | ||
12103 | if (incomingdeselect.AgentData.SessionID != SessionId || | ||
12104 | incomingdeselect.AgentData.AgentID != AgentId) | ||
12105 | break; | ||
12106 | } | ||
12107 | #endregion | ||
12108 | |||
12109 | ObjectDeselect handlerObjectDeselect = null; | ||
12110 | |||
12111 | for (int i = 0; i < incomingdeselect.ObjectData.Length; i++) | ||
12112 | { | ||
12113 | handlerObjectDeselect = OnObjectDeselect; | ||
12114 | if (handlerObjectDeselect != null) | ||
12115 | { | ||
12116 | OnObjectDeselect(incomingdeselect.ObjectData[i].ObjectLocalID, this); | ||
12117 | } | ||
12118 | } | ||
12119 | break; | ||
12120 | |||
12121 | case PacketType.ObjectPosition: | ||
12122 | // DEPRECATED: but till libsecondlife removes it, people will use it | ||
12123 | ObjectPositionPacket position = (ObjectPositionPacket)Pack; | ||
12124 | |||
12125 | #region Packet Session and User Check | ||
12126 | if (m_checkPackets) | ||
12127 | { | ||
12128 | if (position.AgentData.SessionID != SessionId || | ||
12129 | position.AgentData.AgentID != AgentId) | ||
12130 | break; | ||
12131 | } | ||
12132 | #endregion | ||
12133 | |||
12134 | |||
12135 | for (int i = 0; i < position.ObjectData.Length; i++) | ||
12136 | { | ||
12137 | UpdateVector handlerUpdateVector = OnUpdatePrimGroupPosition; | ||
12138 | if (handlerUpdateVector != null) | ||
12139 | handlerUpdateVector(position.ObjectData[i].ObjectLocalID, position.ObjectData[i].Position, this); | ||
12140 | } | ||
12141 | |||
12142 | break; | ||
12143 | |||
12144 | case PacketType.ObjectScale: | ||
12145 | // DEPRECATED: but till libsecondlife removes it, people will use it | ||
12146 | ObjectScalePacket scale = (ObjectScalePacket)Pack; | ||
12147 | |||
12148 | #region Packet Session and User Check | ||
12149 | if (m_checkPackets) | ||
12150 | { | ||
12151 | if (scale.AgentData.SessionID != SessionId || | ||
12152 | scale.AgentData.AgentID != AgentId) | ||
12153 | break; | ||
12154 | } | ||
12155 | #endregion | ||
12156 | |||
12157 | for (int i = 0; i < scale.ObjectData.Length; i++) | ||
12158 | { | ||
12159 | UpdateVector handlerUpdatePrimGroupScale = OnUpdatePrimGroupScale; | ||
12160 | if (handlerUpdatePrimGroupScale != null) | ||
12161 | handlerUpdatePrimGroupScale(scale.ObjectData[i].ObjectLocalID, scale.ObjectData[i].Scale, this); | ||
12162 | } | ||
12163 | |||
12164 | break; | ||
12165 | |||
12166 | case PacketType.ObjectRotation: | ||
12167 | // DEPRECATED: but till libsecondlife removes it, people will use it | ||
12168 | ObjectRotationPacket rotation = (ObjectRotationPacket)Pack; | ||
12169 | |||
12170 | #region Packet Session and User Check | ||
12171 | if (m_checkPackets) | ||
12172 | { | ||
12173 | if (rotation.AgentData.SessionID != SessionId || | ||
12174 | rotation.AgentData.AgentID != AgentId) | ||
12175 | break; | ||
12176 | } | ||
12177 | #endregion | ||
12178 | |||
12179 | for (int i = 0; i < rotation.ObjectData.Length; i++) | ||
12180 | { | ||
12181 | UpdatePrimRotation handlerUpdatePrimRotation = OnUpdatePrimGroupRotation; | ||
12182 | if (handlerUpdatePrimRotation != null) | ||
12183 | handlerUpdatePrimRotation(rotation.ObjectData[i].ObjectLocalID, rotation.ObjectData[i].Rotation, this); | ||
12184 | } | ||
12185 | |||
12186 | break; | ||
12187 | |||
12188 | case PacketType.ObjectFlagUpdate: | ||
12189 | ObjectFlagUpdatePacket flags = (ObjectFlagUpdatePacket)Pack; | ||
12190 | |||
12191 | #region Packet Session and User Check | ||
12192 | if (m_checkPackets) | ||
12193 | { | ||
12194 | if (flags.AgentData.SessionID != SessionId || | ||
12195 | flags.AgentData.AgentID != AgentId) | ||
12196 | break; | ||
12197 | } | ||
12198 | #endregion | ||
12199 | |||
12200 | UpdatePrimFlags handlerUpdatePrimFlags = OnUpdatePrimFlags; | ||
12201 | |||
12202 | if (handlerUpdatePrimFlags != null) | ||
12203 | { | ||
12204 | byte[] data = Pack.ToBytes(); | ||
12205 | // 46,47,48 are special positions within the packet | ||
12206 | // This may change so perhaps we need a better way | ||
12207 | // of storing this (OMV.FlagUpdatePacket.UsePhysics,etc?) | ||
12208 | bool UsePhysics = (data[46] != 0) ? true : false; | ||
12209 | bool IsTemporary = (data[47] != 0) ? true : false; | ||
12210 | bool IsPhantom = (data[48] != 0) ? true : false; | ||
12211 | handlerUpdatePrimFlags(flags.AgentData.ObjectLocalID, UsePhysics, IsTemporary, IsPhantom, this); | ||
12212 | } | ||
12213 | break; | ||
12214 | case PacketType.ObjectImage: | ||
12215 | ObjectImagePacket imagePack = (ObjectImagePacket)Pack; | ||
12216 | |||
12217 | UpdatePrimTexture handlerUpdatePrimTexture = null; | ||
12218 | for (int i = 0; i < imagePack.ObjectData.Length; i++) | ||
12219 | { | ||
12220 | handlerUpdatePrimTexture = OnUpdatePrimTexture; | ||
12221 | if (handlerUpdatePrimTexture != null) | ||
12222 | { | ||
12223 | handlerUpdatePrimTexture(imagePack.ObjectData[i].ObjectLocalID, | ||
12224 | imagePack.ObjectData[i].TextureEntry, this); | ||
12225 | } | ||
12226 | } | ||
12227 | break; | ||
12228 | |||
12229 | case PacketType.ObjectGrab: | ||
12230 | ObjectGrabPacket grab = (ObjectGrabPacket)Pack; | ||
12231 | |||
12232 | #region Packet Session and User Check | ||
12233 | if (m_checkPackets) | ||
12234 | { | ||
12235 | if (grab.AgentData.SessionID != SessionId || | ||
12236 | grab.AgentData.AgentID != AgentId) | ||
12237 | break; | ||
12238 | } | ||
12239 | #endregion | ||
12240 | |||
12241 | GrabObject handlerGrabObject = OnGrabObject; | ||
12242 | |||
12243 | if (handlerGrabObject != null) | ||
12244 | { | ||
12245 | List<SurfaceTouchEventArgs> touchArgs = new List<SurfaceTouchEventArgs>(); | ||
12246 | if ((grab.SurfaceInfo != null) && (grab.SurfaceInfo.Length > 0)) | ||
12247 | { | ||
12248 | foreach (ObjectGrabPacket.SurfaceInfoBlock surfaceInfo in grab.SurfaceInfo) | ||
12249 | { | ||
12250 | SurfaceTouchEventArgs arg = new SurfaceTouchEventArgs(); | ||
12251 | arg.Binormal = surfaceInfo.Binormal; | ||
12252 | arg.FaceIndex = surfaceInfo.FaceIndex; | ||
12253 | arg.Normal = surfaceInfo.Normal; | ||
12254 | arg.Position = surfaceInfo.Position; | ||
12255 | arg.STCoord = surfaceInfo.STCoord; | ||
12256 | arg.UVCoord = surfaceInfo.UVCoord; | ||
12257 | touchArgs.Add(arg); | ||
12258 | } | ||
12259 | } | ||
12260 | handlerGrabObject(grab.ObjectData.LocalID, grab.ObjectData.GrabOffset, this, touchArgs); | ||
12261 | } | ||
12262 | break; | ||
12263 | |||
12264 | case PacketType.ObjectGrabUpdate: | ||
12265 | ObjectGrabUpdatePacket grabUpdate = (ObjectGrabUpdatePacket)Pack; | ||
12266 | |||
12267 | #region Packet Session and User Check | ||
12268 | if (m_checkPackets) | ||
12269 | { | ||
12270 | if (grabUpdate.AgentData.SessionID != SessionId || | ||
12271 | grabUpdate.AgentData.AgentID != AgentId) | ||
12272 | break; | ||
12273 | } | ||
12274 | #endregion | ||
12275 | |||
12276 | MoveObject handlerGrabUpdate = OnGrabUpdate; | ||
12277 | |||
12278 | if (handlerGrabUpdate != null) | ||
12279 | { | ||
12280 | List<SurfaceTouchEventArgs> touchArgs = new List<SurfaceTouchEventArgs>(); | ||
12281 | if ((grabUpdate.SurfaceInfo != null) && (grabUpdate.SurfaceInfo.Length > 0)) | ||
12282 | { | ||
12283 | foreach (ObjectGrabUpdatePacket.SurfaceInfoBlock surfaceInfo in grabUpdate.SurfaceInfo) | ||
12284 | { | ||
12285 | SurfaceTouchEventArgs arg = new SurfaceTouchEventArgs(); | ||
12286 | arg.Binormal = surfaceInfo.Binormal; | ||
12287 | arg.FaceIndex = surfaceInfo.FaceIndex; | ||
12288 | arg.Normal = surfaceInfo.Normal; | ||
12289 | arg.Position = surfaceInfo.Position; | ||
12290 | arg.STCoord = surfaceInfo.STCoord; | ||
12291 | arg.UVCoord = surfaceInfo.UVCoord; | ||
12292 | touchArgs.Add(arg); | ||
12293 | } | ||
12294 | } | ||
12295 | handlerGrabUpdate(grabUpdate.ObjectData.ObjectID, grabUpdate.ObjectData.GrabOffsetInitial, | ||
12296 | grabUpdate.ObjectData.GrabPosition, this, touchArgs); | ||
12297 | } | ||
12298 | break; | ||
12299 | |||
12300 | case PacketType.ObjectDeGrab: | ||
12301 | ObjectDeGrabPacket deGrab = (ObjectDeGrabPacket)Pack; | ||
12302 | |||
12303 | #region Packet Session and User Check | ||
12304 | if (m_checkPackets) | ||
12305 | { | ||
12306 | if (deGrab.AgentData.SessionID != SessionId || | ||
12307 | deGrab.AgentData.AgentID != AgentId) | ||
12308 | break; | ||
12309 | } | ||
12310 | #endregion | ||
12311 | |||
12312 | DeGrabObject handlerDeGrabObject = OnDeGrabObject; | ||
12313 | if (handlerDeGrabObject != null) | ||
12314 | { | ||
12315 | List<SurfaceTouchEventArgs> touchArgs = new List<SurfaceTouchEventArgs>(); | ||
12316 | if ((deGrab.SurfaceInfo != null) && (deGrab.SurfaceInfo.Length > 0)) | ||
12317 | { | ||
12318 | foreach (ObjectDeGrabPacket.SurfaceInfoBlock surfaceInfo in deGrab.SurfaceInfo) | ||
12319 | { | ||
12320 | SurfaceTouchEventArgs arg = new SurfaceTouchEventArgs(); | ||
12321 | arg.Binormal = surfaceInfo.Binormal; | ||
12322 | arg.FaceIndex = surfaceInfo.FaceIndex; | ||
12323 | arg.Normal = surfaceInfo.Normal; | ||
12324 | arg.Position = surfaceInfo.Position; | ||
12325 | arg.STCoord = surfaceInfo.STCoord; | ||
12326 | arg.UVCoord = surfaceInfo.UVCoord; | ||
12327 | touchArgs.Add(arg); | ||
12328 | } | ||
12329 | } | ||
12330 | handlerDeGrabObject(deGrab.ObjectData.LocalID, this, touchArgs); | ||
12331 | } | ||
12332 | break; | ||
12333 | |||
12334 | case PacketType.ObjectSpinStart: | ||
12335 | //m_log.Warn("[CLIENT]: unhandled ObjectSpinStart packet"); | ||
12336 | ObjectSpinStartPacket spinStart = (ObjectSpinStartPacket)Pack; | ||
12337 | |||
12338 | #region Packet Session and User Check | ||
12339 | if (m_checkPackets) | ||
12340 | { | ||
12341 | if (spinStart.AgentData.SessionID != SessionId || | ||
12342 | spinStart.AgentData.AgentID != AgentId) | ||
12343 | break; | ||
12344 | } | ||
12345 | #endregion | ||
12346 | |||
12347 | SpinStart handlerSpinStart = OnSpinStart; | ||
12348 | if (handlerSpinStart != null) | ||
12349 | { | ||
12350 | handlerSpinStart(spinStart.ObjectData.ObjectID, this); | ||
12351 | } | ||
12352 | break; | ||
12353 | case PacketType.ObjectSpinUpdate: | ||
12354 | //m_log.Warn("[CLIENT]: unhandled ObjectSpinUpdate packet"); | ||
12355 | ObjectSpinUpdatePacket spinUpdate = (ObjectSpinUpdatePacket)Pack; | ||
12356 | |||
12357 | #region Packet Session and User Check | ||
12358 | if (m_checkPackets) | ||
12359 | { | ||
12360 | if (spinUpdate.AgentData.SessionID != SessionId || | ||
12361 | spinUpdate.AgentData.AgentID != AgentId) | ||
12362 | break; | ||
12363 | } | ||
12364 | #endregion | ||
12365 | |||
12366 | Vector3 axis; | ||
12367 | float angle; | ||
12368 | spinUpdate.ObjectData.Rotation.GetAxisAngle(out axis, out angle); | ||
12369 | //m_log.Warn("[CLIENT]: ObjectSpinUpdate packet rot axis:" + axis + " angle:" + angle); | ||
12370 | |||
12371 | SpinObject handlerSpinUpdate = OnSpinUpdate; | ||
12372 | if (handlerSpinUpdate != null) | ||
12373 | { | ||
12374 | handlerSpinUpdate(spinUpdate.ObjectData.ObjectID, spinUpdate.ObjectData.Rotation, this); | ||
12375 | } | ||
12376 | break; | ||
12377 | |||
12378 | |||
12379 | case PacketType.ObjectSpinStop: | ||
12380 | //m_log.Warn("[CLIENT]: unhandled ObjectSpinStop packet"); | ||
12381 | ObjectSpinStopPacket spinStop = (ObjectSpinStopPacket)Pack; | ||
12382 | |||
12383 | #region Packet Session and User Check | ||
12384 | if (m_checkPackets) | ||
12385 | { | ||
12386 | if (spinStop.AgentData.SessionID != SessionId || | ||
12387 | spinStop.AgentData.AgentID != AgentId) | ||
12388 | break; | ||
12389 | } | ||
12390 | #endregion | ||
12391 | |||
12392 | SpinStop handlerSpinStop = OnSpinStop; | ||
12393 | if (handlerSpinStop != null) | ||
12394 | { | ||
12395 | handlerSpinStop(spinStop.ObjectData.ObjectID, this); | ||
12396 | } | ||
12397 | break; | ||
12398 | |||
12399 | case PacketType.ObjectDescription: | ||
12400 | ObjectDescriptionPacket objDes = (ObjectDescriptionPacket)Pack; | ||
12401 | |||
12402 | #region Packet Session and User Check | ||
12403 | if (m_checkPackets) | ||
12404 | { | ||
12405 | if (objDes.AgentData.SessionID != SessionId || | ||
12406 | objDes.AgentData.AgentID != AgentId) | ||
12407 | break; | ||
12408 | } | ||
12409 | #endregion | ||
12410 | |||
12411 | GenericCall7 handlerObjectDescription = null; | ||
12412 | |||
12413 | for (int i = 0; i < objDes.ObjectData.Length; i++) | ||
12414 | { | ||
12415 | handlerObjectDescription = OnObjectDescription; | ||
12416 | if (handlerObjectDescription != null) | ||
12417 | { | ||
12418 | handlerObjectDescription(this, objDes.ObjectData[i].LocalID, | ||
12419 | Util.FieldToString(objDes.ObjectData[i].Description)); | ||
12420 | } | ||
12421 | } | ||
12422 | break; | ||
12423 | |||
12424 | case PacketType.ObjectName: | ||
12425 | ObjectNamePacket objName = (ObjectNamePacket)Pack; | ||
12426 | |||
12427 | #region Packet Session and User Check | ||
12428 | if (m_checkPackets) | ||
12429 | { | ||
12430 | if (objName.AgentData.SessionID != SessionId || | ||
12431 | objName.AgentData.AgentID != AgentId) | ||
12432 | break; | ||
12433 | } | ||
12434 | #endregion | ||
12435 | |||
12436 | GenericCall7 handlerObjectName = null; | ||
12437 | for (int i = 0; i < objName.ObjectData.Length; i++) | ||
12438 | { | ||
12439 | handlerObjectName = OnObjectName; | ||
12440 | if (handlerObjectName != null) | ||
12441 | { | ||
12442 | handlerObjectName(this, objName.ObjectData[i].LocalID, | ||
12443 | Util.FieldToString(objName.ObjectData[i].Name)); | ||
12444 | } | ||
12445 | } | ||
12446 | break; | ||
12447 | |||
12448 | case PacketType.ObjectPermissions: | ||
12449 | if (OnObjectPermissions != null) | ||
12450 | { | ||
12451 | ObjectPermissionsPacket newobjPerms = (ObjectPermissionsPacket)Pack; | ||
12452 | |||
12453 | #region Packet Session and User Check | ||
12454 | if (m_checkPackets) | ||
12455 | { | ||
12456 | if (newobjPerms.AgentData.SessionID != SessionId || | ||
12457 | newobjPerms.AgentData.AgentID != AgentId) | ||
12458 | break; | ||
12459 | } | ||
12460 | #endregion | ||
12461 | |||
12462 | UUID AgentID = newobjPerms.AgentData.AgentID; | ||
12463 | UUID SessionID = newobjPerms.AgentData.SessionID; | ||
12464 | |||
12465 | ObjectPermissions handlerObjectPermissions = null; | ||
12466 | |||
12467 | for (int i = 0; i < newobjPerms.ObjectData.Length; i++) | ||
12468 | { | ||
12469 | ObjectPermissionsPacket.ObjectDataBlock permChanges = newobjPerms.ObjectData[i]; | ||
12470 | |||
12471 | byte field = permChanges.Field; | ||
12472 | uint localID = permChanges.ObjectLocalID; | ||
12473 | uint mask = permChanges.Mask; | ||
12474 | byte set = permChanges.Set; | ||
12475 | |||
12476 | handlerObjectPermissions = OnObjectPermissions; | ||
12477 | |||
12478 | if (handlerObjectPermissions != null) | ||
12479 | handlerObjectPermissions(this, AgentID, SessionID, field, localID, mask, set); | ||
12480 | } | ||
12481 | } | ||
12482 | |||
12483 | // Here's our data, | ||
12484 | // PermField contains the field the info goes into | ||
12485 | // PermField determines which mask we're changing | ||
12486 | // | ||
12487 | // chmask is the mask of the change | ||
12488 | // setTF is whether we're adding it or taking it away | ||
12489 | // | ||
12490 | // objLocalID is the localID of the object. | ||
12491 | |||
12492 | // Unfortunately, we have to pass the event the packet because objData is an array | ||
12493 | // That means multiple object perms may be updated in a single packet. | ||
12494 | |||
12495 | break; | ||
12496 | |||
12497 | case PacketType.Undo: | ||
12498 | UndoPacket undoitem = (UndoPacket)Pack; | ||
12499 | |||
12500 | #region Packet Session and User Check | ||
12501 | if (m_checkPackets) | ||
12502 | { | ||
12503 | if (undoitem.AgentData.SessionID != SessionId || | ||
12504 | undoitem.AgentData.AgentID != AgentId) | ||
12505 | break; | ||
12506 | } | ||
12507 | #endregion | ||
12508 | |||
12509 | if (undoitem.ObjectData.Length > 0) | ||
12510 | { | ||
12511 | for (int i = 0; i < undoitem.ObjectData.Length; i++) | ||
12512 | { | ||
12513 | UUID objiD = undoitem.ObjectData[i].ObjectID; | ||
12514 | AgentSit handlerOnUndo = OnUndo; | ||
12515 | if (handlerOnUndo != null) | ||
12516 | { | ||
12517 | handlerOnUndo(this, objiD); | ||
12518 | } | ||
12519 | |||
12520 | } | ||
12521 | } | ||
12522 | break; | ||
12523 | |||
12524 | case PacketType.ObjectDuplicateOnRay: | ||
12525 | ObjectDuplicateOnRayPacket dupeOnRay = (ObjectDuplicateOnRayPacket)Pack; | ||
12526 | |||
12527 | #region Packet Session and User Check | ||
12528 | if (m_checkPackets) | ||
12529 | { | ||
12530 | if (dupeOnRay.AgentData.SessionID != SessionId || | ||
12531 | dupeOnRay.AgentData.AgentID != AgentId) | ||
12532 | break; | ||
12533 | } | ||
12534 | #endregion | ||
12535 | |||
12536 | ObjectDuplicateOnRay handlerObjectDuplicateOnRay = null; | ||
12537 | |||
12538 | for (int i = 0; i < dupeOnRay.ObjectData.Length; i++) | ||
12539 | { | ||
12540 | handlerObjectDuplicateOnRay = OnObjectDuplicateOnRay; | ||
12541 | if (handlerObjectDuplicateOnRay != null) | ||
12542 | { | ||
12543 | handlerObjectDuplicateOnRay(dupeOnRay.ObjectData[i].ObjectLocalID, dupeOnRay.AgentData.DuplicateFlags, | ||
12544 | dupeOnRay.AgentData.AgentID, dupeOnRay.AgentData.GroupID, dupeOnRay.AgentData.RayTargetID, dupeOnRay.AgentData.RayEnd, | ||
12545 | dupeOnRay.AgentData.RayStart, dupeOnRay.AgentData.BypassRaycast, dupeOnRay.AgentData.RayEndIsIntersection, | ||
12546 | dupeOnRay.AgentData.CopyCenters, dupeOnRay.AgentData.CopyRotates); | ||
12547 | } | ||
12548 | } | ||
12549 | |||
12550 | break; | ||
12551 | |||
12552 | case PacketType.RequestObjectPropertiesFamily: | ||
12553 | //This powers the little tooltip that appears when you move your mouse over an object | ||
12554 | RequestObjectPropertiesFamilyPacket packToolTip = (RequestObjectPropertiesFamilyPacket)Pack; | ||
12555 | |||
12556 | #region Packet Session and User Check | ||
12557 | if (m_checkPackets) | ||
12558 | { | ||
12559 | if (packToolTip.AgentData.SessionID != SessionId || | ||
12560 | packToolTip.AgentData.AgentID != AgentId) | ||
12561 | break; | ||
12562 | } | ||
12563 | #endregion | ||
12564 | |||
12565 | RequestObjectPropertiesFamilyPacket.ObjectDataBlock packObjBlock = packToolTip.ObjectData; | ||
12566 | |||
12567 | RequestObjectPropertiesFamily handlerRequestObjectPropertiesFamily = OnRequestObjectPropertiesFamily; | ||
12568 | |||
12569 | if (handlerRequestObjectPropertiesFamily != null) | ||
12570 | { | ||
12571 | handlerRequestObjectPropertiesFamily(this, m_agentId, packObjBlock.RequestFlags, | ||
12572 | packObjBlock.ObjectID); | ||
12573 | } | ||
12574 | |||
12575 | break; | ||
12576 | |||
12577 | case PacketType.ObjectIncludeInSearch: | ||
12578 | //This lets us set objects to appear in search (stuff like DataSnapshot, etc) | ||
12579 | ObjectIncludeInSearchPacket packInSearch = (ObjectIncludeInSearchPacket)Pack; | ||
12580 | ObjectIncludeInSearch handlerObjectIncludeInSearch = null; | ||
12581 | |||
12582 | #region Packet Session and User Check | ||
12583 | if (m_checkPackets) | ||
12584 | { | ||
12585 | if (packInSearch.AgentData.SessionID != SessionId || | ||
12586 | packInSearch.AgentData.AgentID != AgentId) | ||
12587 | break; | ||
12588 | } | ||
12589 | #endregion | ||
12590 | |||
12591 | foreach (ObjectIncludeInSearchPacket.ObjectDataBlock objData in packInSearch.ObjectData) | ||
12592 | { | ||
12593 | bool inSearch = objData.IncludeInSearch; | ||
12594 | uint localID = objData.ObjectLocalID; | ||
12595 | |||
12596 | handlerObjectIncludeInSearch = OnObjectIncludeInSearch; | ||
12597 | |||
12598 | if (handlerObjectIncludeInSearch != null) | ||
12599 | { | ||
12600 | handlerObjectIncludeInSearch(this, inSearch, localID); | ||
12601 | } | ||
12602 | } | ||
12603 | break; | ||
12604 | |||
12605 | case PacketType.ScriptAnswerYes: | ||
12606 | ScriptAnswerYesPacket scriptAnswer = (ScriptAnswerYesPacket)Pack; | ||
12607 | |||
12608 | #region Packet Session and User Check | ||
12609 | if (m_checkPackets) | ||
12610 | { | ||
12611 | if (scriptAnswer.AgentData.SessionID != SessionId || | ||
12612 | scriptAnswer.AgentData.AgentID != AgentId) | ||
12613 | break; | ||
12614 | } | ||
12615 | #endregion | ||
12616 | |||
12617 | ScriptAnswer handlerScriptAnswer = OnScriptAnswer; | ||
12618 | if (handlerScriptAnswer != null) | ||
12619 | { | ||
12620 | handlerScriptAnswer(this, scriptAnswer.Data.TaskID, scriptAnswer.Data.ItemID, scriptAnswer.Data.Questions); | ||
12621 | } | ||
12622 | break; | ||
12623 | |||
12624 | case PacketType.ObjectClickAction: | ||
12625 | ObjectClickActionPacket ocpacket = (ObjectClickActionPacket)Pack; | ||
12626 | |||
12627 | #region Packet Session and User Check | ||
12628 | if (m_checkPackets) | ||
12629 | { | ||
12630 | if (ocpacket.AgentData.SessionID != SessionId || | ||
12631 | ocpacket.AgentData.AgentID != AgentId) | ||
12632 | break; | ||
12633 | } | ||
12634 | #endregion | ||
12635 | |||
12636 | GenericCall7 handlerObjectClickAction = OnObjectClickAction; | ||
12637 | if (handlerObjectClickAction != null) | ||
12638 | { | ||
12639 | foreach (ObjectClickActionPacket.ObjectDataBlock odata in ocpacket.ObjectData) | ||
12640 | { | ||
12641 | byte action = odata.ClickAction; | ||
12642 | uint localID = odata.ObjectLocalID; | ||
12643 | handlerObjectClickAction(this, localID, action.ToString()); | ||
12644 | } | ||
12645 | } | ||
12646 | break; | ||
12647 | |||
12648 | case PacketType.ObjectMaterial: | ||
12649 | ObjectMaterialPacket ompacket = (ObjectMaterialPacket)Pack; | ||
12650 | |||
12651 | #region Packet Session and User Check | ||
12652 | if (m_checkPackets) | ||
12653 | { | ||
12654 | if (ompacket.AgentData.SessionID != SessionId || | ||
12655 | ompacket.AgentData.AgentID != AgentId) | ||
12656 | break; | ||
12657 | } | ||
12658 | #endregion | ||
12659 | |||
12660 | GenericCall7 handlerObjectMaterial = OnObjectMaterial; | ||
12661 | if (handlerObjectMaterial != null) | ||
12662 | { | ||
12663 | foreach (ObjectMaterialPacket.ObjectDataBlock odata in ompacket.ObjectData) | ||
12664 | { | ||
12665 | byte material = odata.Material; | ||
12666 | uint localID = odata.ObjectLocalID; | ||
12667 | handlerObjectMaterial(this, localID, material.ToString()); | ||
12668 | } | ||
12669 | } | ||
12670 | break; | ||
12671 | |||
12672 | //#endregion | ||
12673 | |||
12674 | //#region Inventory/Asset/Other related packets | ||
12675 | |||
12676 | case PacketType.RequestImage: | ||
12677 | RequestImagePacket imageRequest = (RequestImagePacket)Pack; | ||
12678 | //m_log.Debug("image request: " + Pack.ToString()); | ||
12679 | |||
12680 | #region Packet Session and User Check | ||
12681 | if (m_checkPackets) | ||
12682 | { | ||
12683 | if (imageRequest.AgentData.SessionID != SessionId || | ||
12684 | imageRequest.AgentData.AgentID != AgentId) | ||
12685 | break; | ||
12686 | } | ||
12687 | #endregion | ||
12688 | |||
12689 | //handlerTextureRequest = null; | ||
12690 | for (int i = 0; i < imageRequest.RequestImage.Length; i++) | ||
12691 | { | ||
12692 | if (OnRequestTexture != null) | ||
12693 | { | ||
12694 | TextureRequestArgs args = new TextureRequestArgs(); | ||
12695 | |||
12696 | RequestImagePacket.RequestImageBlock block = imageRequest.RequestImage[i]; | ||
12697 | |||
12698 | args.RequestedAssetID = block.Image; | ||
12699 | args.DiscardLevel = block.DiscardLevel; | ||
12700 | args.PacketNumber = block.Packet; | ||
12701 | args.Priority = block.DownloadPriority; | ||
12702 | args.requestSequence = imageRequest.Header.Sequence; | ||
12703 | |||
12704 | // NOTE: This is not a built in part of the LLUDP protocol, but we double the | ||
12705 | // priority of avatar textures to get avatars rezzing in faster than the | ||
12706 | // surrounding scene | ||
12707 | if ((ImageType)block.Type == ImageType.Baked) | ||
12708 | args.Priority *= 2.0f; | ||
12709 | |||
12710 | //handlerTextureRequest = OnRequestTexture; | ||
12711 | |||
12712 | //if (handlerTextureRequest != null) | ||
12713 | //OnRequestTexture(this, args); | ||
12714 | |||
12715 | // in the end, we null this, so we have to check if it's null | ||
12716 | if (m_imageManager != null) | ||
12717 | { | ||
12718 | m_imageManager.EnqueueReq(args); | ||
12719 | } | ||
12720 | } | ||
12721 | } | ||
12722 | break; | ||
12723 | |||
12724 | case PacketType.TransferRequest: | ||
12725 | //m_log.Debug("ClientView.ProcessPackets.cs:ProcessInPacket() - Got transfer request"); | ||
12726 | |||
12727 | TransferRequestPacket transfer = (TransferRequestPacket)Pack; | ||
12728 | //m_log.Debug("Transfer Request: " + transfer.ToString()); | ||
12729 | // Validate inventory transfers | ||
12730 | // Has to be done here, because AssetCache can't do it | ||
12731 | // | ||
12732 | UUID taskID = UUID.Zero; | ||
12733 | if (transfer.TransferInfo.SourceType == 3) | ||
12734 | { | ||
12735 | taskID = new UUID(transfer.TransferInfo.Params, 48); | ||
12736 | UUID itemID = new UUID(transfer.TransferInfo.Params, 64); | ||
12737 | UUID requestID = new UUID(transfer.TransferInfo.Params, 80); | ||
12738 | if (!(((Scene)m_scene).Permissions.BypassPermissions())) | ||
12739 | { | ||
12740 | if (taskID != UUID.Zero) // Prim | ||
12741 | { | ||
12742 | SceneObjectPart part = ((Scene)m_scene).GetSceneObjectPart(taskID); | ||
12743 | if (part == null) | ||
12744 | break; | ||
12745 | |||
12746 | if (part.OwnerID != AgentId) | ||
12747 | break; | ||
12748 | |||
12749 | if ((part.OwnerMask & (uint)PermissionMask.Modify) == 0) | ||
12750 | break; | ||
12751 | |||
12752 | TaskInventoryItem ti = part.Inventory.GetInventoryItem(itemID); | ||
12753 | if (ti == null) | ||
12754 | break; | ||
12755 | |||
12756 | if (ti.OwnerID != AgentId) | ||
12757 | break; | ||
12758 | |||
12759 | if ((ti.CurrentPermissions & ((uint)PermissionMask.Modify | (uint)PermissionMask.Copy | (uint)PermissionMask.Transfer)) != ((uint)PermissionMask.Modify | (uint)PermissionMask.Copy | (uint)PermissionMask.Transfer)) | ||
12760 | break; | ||
12761 | |||
12762 | if (ti.AssetID != requestID) | ||
12763 | break; | ||
12764 | } | ||
12765 | else // Agent | ||
12766 | { | ||
12767 | IInventoryService invService = m_scene.RequestModuleInterface<IInventoryService>(); | ||
12768 | InventoryItemBase assetRequestItem = new InventoryItemBase(itemID, AgentId); | ||
12769 | assetRequestItem = invService.GetItem(assetRequestItem); | ||
12770 | if (assetRequestItem == null) | ||
12771 | { | ||
12772 | assetRequestItem = ((Scene)m_scene).CommsManager.UserProfileCacheService.LibraryRoot.FindItem(itemID); | ||
12773 | if (assetRequestItem == null) | ||
12774 | return; | ||
12775 | } | ||
12776 | |||
12777 | // At this point, we need to apply perms | ||
12778 | // only to notecards and scripts. All | ||
12779 | // other asset types are always available | ||
12780 | // | ||
12781 | if (assetRequestItem.AssetType == 10) | ||
12782 | { | ||
12783 | if (!((Scene)m_scene).Permissions.CanViewScript(itemID, UUID.Zero, AgentId)) | ||
12784 | { | ||
12785 | SendAgentAlertMessage("Insufficient permissions to view script", false); | ||
12786 | break; | ||
12787 | } | ||
12788 | } | ||
12789 | else if (assetRequestItem.AssetType == 7) | ||
12790 | { | ||
12791 | if (!((Scene)m_scene).Permissions.CanViewNotecard(itemID, UUID.Zero, AgentId)) | ||
12792 | { | ||
12793 | SendAgentAlertMessage("Insufficient permissions to view notecard", false); | ||
12794 | break; | ||
12795 | } | ||
12796 | } | ||
12797 | |||
12798 | if (assetRequestItem.AssetID != requestID) | ||
12799 | break; | ||
12800 | } | ||
12801 | } | ||
12802 | } | ||
12803 | |||
12804 | //m_assetCache.AddAssetRequest(this, transfer); | ||
12805 | |||
12806 | MakeAssetRequest(transfer, taskID); | ||
12807 | |||
12808 | // RequestAsset = OnRequestAsset; | ||
12809 | // if (RequestAsset != null) | ||
12810 | // { | ||
12811 | // RequestAsset(this, transfer); | ||
12812 | // } | ||
12813 | |||
12814 | break; | ||
12815 | |||
12816 | case PacketType.AssetUploadRequest: | ||
12817 | AssetUploadRequestPacket request = (AssetUploadRequestPacket)Pack; | ||
12818 | |||
12819 | |||
12820 | // m_log.Debug("upload request " + request.ToString()); | ||
12821 | // m_log.Debug("upload request was for assetid: " + request.AssetBlock.TransactionID.Combine(this.SecureSessionId).ToString()); | ||
12822 | UUID temp = UUID.Combine(request.AssetBlock.TransactionID, SecureSessionId); | ||
12823 | |||
12824 | UDPAssetUploadRequest handlerAssetUploadRequest = OnAssetUploadRequest; | ||
12825 | |||
12826 | if (handlerAssetUploadRequest != null) | ||
12827 | { | ||
12828 | handlerAssetUploadRequest(this, temp, | ||
12829 | request.AssetBlock.TransactionID, request.AssetBlock.Type, | ||
12830 | request.AssetBlock.AssetData, request.AssetBlock.StoreLocal, | ||
12831 | request.AssetBlock.Tempfile); | ||
12832 | } | ||
12833 | break; | ||
12834 | |||
12835 | case PacketType.RequestXfer: | ||
12836 | RequestXferPacket xferReq = (RequestXferPacket)Pack; | ||
12837 | |||
12838 | RequestXfer handlerRequestXfer = OnRequestXfer; | ||
12839 | |||
12840 | if (handlerRequestXfer != null) | ||
12841 | { | ||
12842 | handlerRequestXfer(this, xferReq.XferID.ID, Util.FieldToString(xferReq.XferID.Filename)); | ||
12843 | } | ||
12844 | break; | ||
12845 | |||
12846 | case PacketType.SendXferPacket: | ||
12847 | SendXferPacketPacket xferRec = (SendXferPacketPacket)Pack; | ||
12848 | |||
12849 | XferReceive handlerXferReceive = OnXferReceive; | ||
12850 | if (handlerXferReceive != null) | ||
12851 | { | ||
12852 | handlerXferReceive(this, xferRec.XferID.ID, xferRec.XferID.Packet, xferRec.DataPacket.Data); | ||
12853 | } | ||
12854 | break; | ||
12855 | |||
12856 | case PacketType.ConfirmXferPacket: | ||
12857 | ConfirmXferPacketPacket confirmXfer = (ConfirmXferPacketPacket)Pack; | ||
12858 | |||
12859 | ConfirmXfer handlerConfirmXfer = OnConfirmXfer; | ||
12860 | if (handlerConfirmXfer != null) | ||
12861 | { | ||
12862 | handlerConfirmXfer(this, confirmXfer.XferID.ID, confirmXfer.XferID.Packet); | ||
12863 | } | ||
12864 | break; | ||
12865 | |||
12866 | case PacketType.AbortXfer: | ||
12867 | AbortXferPacket abortXfer = (AbortXferPacket)Pack; | ||
12868 | AbortXfer handlerAbortXfer = OnAbortXfer; | ||
12869 | if (handlerAbortXfer != null) | ||
12870 | { | ||
12871 | handlerAbortXfer(this, abortXfer.XferID.ID); | ||
12872 | } | ||
12873 | |||
12874 | break; | ||
12875 | |||
12876 | case PacketType.CreateInventoryFolder: | ||
12877 | CreateInventoryFolderPacket invFolder = (CreateInventoryFolderPacket)Pack; | ||
12878 | |||
12879 | #region Packet Session and User Check | ||
12880 | if (m_checkPackets) | ||
12881 | { | ||
12882 | if (invFolder.AgentData.SessionID != SessionId || | ||
12883 | invFolder.AgentData.AgentID != AgentId) | ||
12884 | break; | ||
12885 | } | ||
12886 | #endregion | ||
12887 | |||
12888 | CreateInventoryFolder handlerCreateInventoryFolder = OnCreateNewInventoryFolder; | ||
12889 | if (handlerCreateInventoryFolder != null) | ||
12890 | { | ||
12891 | handlerCreateInventoryFolder(this, invFolder.FolderData.FolderID, | ||
12892 | (ushort)invFolder.FolderData.Type, | ||
12893 | Util.FieldToString(invFolder.FolderData.Name), | ||
12894 | invFolder.FolderData.ParentID); | ||
12895 | } | ||
12896 | break; | ||
12897 | |||
12898 | case PacketType.UpdateInventoryFolder: | ||
12899 | if (OnUpdateInventoryFolder != null) | ||
12900 | { | ||
12901 | UpdateInventoryFolderPacket invFolderx = (UpdateInventoryFolderPacket)Pack; | ||
12902 | |||
12903 | #region Packet Session and User Check | ||
12904 | if (m_checkPackets) | ||
12905 | { | ||
12906 | if (invFolderx.AgentData.SessionID != SessionId || | ||
12907 | invFolderx.AgentData.AgentID != AgentId) | ||
12908 | break; | ||
12909 | } | ||
12910 | #endregion | ||
12911 | |||
12912 | UpdateInventoryFolder handlerUpdateInventoryFolder = null; | ||
12913 | |||
12914 | for (int i = 0; i < invFolderx.FolderData.Length; i++) | ||
12915 | { | ||
12916 | handlerUpdateInventoryFolder = OnUpdateInventoryFolder; | ||
12917 | if (handlerUpdateInventoryFolder != null) | ||
12918 | { | ||
12919 | OnUpdateInventoryFolder(this, invFolderx.FolderData[i].FolderID, | ||
12920 | (ushort)invFolderx.FolderData[i].Type, | ||
12921 | Util.FieldToString(invFolderx.FolderData[i].Name), | ||
12922 | invFolderx.FolderData[i].ParentID); | ||
12923 | } | ||
12924 | } | ||
12925 | } | ||
12926 | break; | ||
12927 | |||
12928 | case PacketType.MoveInventoryFolder: | ||
12929 | if (OnMoveInventoryFolder != null) | ||
12930 | { | ||
12931 | MoveInventoryFolderPacket invFoldery = (MoveInventoryFolderPacket)Pack; | ||
12932 | |||
12933 | #region Packet Session and User Check | ||
12934 | if (m_checkPackets) | ||
12935 | { | ||
12936 | if (invFoldery.AgentData.SessionID != SessionId || | ||
12937 | invFoldery.AgentData.AgentID != AgentId) | ||
12938 | break; | ||
12939 | } | ||
12940 | #endregion | ||
12941 | |||
12942 | MoveInventoryFolder handlerMoveInventoryFolder = null; | ||
12943 | |||
12944 | for (int i = 0; i < invFoldery.InventoryData.Length; i++) | ||
12945 | { | ||
12946 | handlerMoveInventoryFolder = OnMoveInventoryFolder; | ||
12947 | if (handlerMoveInventoryFolder != null) | ||
12948 | { | ||
12949 | OnMoveInventoryFolder(this, invFoldery.InventoryData[i].FolderID, | ||
12950 | invFoldery.InventoryData[i].ParentID); | ||
12951 | } | ||
12952 | } | ||
12953 | } | ||
12954 | break; | ||
12955 | |||
12956 | case PacketType.CreateInventoryItem: | ||
12957 | CreateInventoryItemPacket createItem = (CreateInventoryItemPacket)Pack; | ||
12958 | |||
12959 | #region Packet Session and User Check | ||
12960 | if (m_checkPackets) | ||
12961 | { | ||
12962 | if (createItem.AgentData.SessionID != SessionId || | ||
12963 | createItem.AgentData.AgentID != AgentId) | ||
12964 | break; | ||
12965 | } | ||
12966 | #endregion | ||
12967 | |||
12968 | CreateNewInventoryItem handlerCreateNewInventoryItem = OnCreateNewInventoryItem; | ||
12969 | if (handlerCreateNewInventoryItem != null) | ||
12970 | { | ||
12971 | handlerCreateNewInventoryItem(this, createItem.InventoryBlock.TransactionID, | ||
12972 | createItem.InventoryBlock.FolderID, | ||
12973 | createItem.InventoryBlock.CallbackID, | ||
12974 | Util.FieldToString(createItem.InventoryBlock.Description), | ||
12975 | Util.FieldToString(createItem.InventoryBlock.Name), | ||
12976 | createItem.InventoryBlock.InvType, | ||
12977 | createItem.InventoryBlock.Type, | ||
12978 | createItem.InventoryBlock.WearableType, | ||
12979 | createItem.InventoryBlock.NextOwnerMask, | ||
12980 | Util.UnixTimeSinceEpoch()); | ||
12981 | } | ||
12982 | break; | ||
12983 | |||
12984 | case PacketType.FetchInventory: | ||
12985 | if (OnFetchInventory != null) | ||
12986 | { | ||
12987 | FetchInventoryPacket FetchInventoryx = (FetchInventoryPacket)Pack; | ||
12988 | |||
12989 | #region Packet Session and User Check | ||
12990 | if (m_checkPackets) | ||
12991 | { | ||
12992 | if (FetchInventoryx.AgentData.SessionID != SessionId || | ||
12993 | FetchInventoryx.AgentData.AgentID != AgentId) | ||
12994 | break; | ||
12995 | } | ||
12996 | #endregion | ||
12997 | |||
12998 | FetchInventory handlerFetchInventory = null; | ||
12999 | |||
13000 | for (int i = 0; i < FetchInventoryx.InventoryData.Length; i++) | ||
13001 | { | ||
13002 | handlerFetchInventory = OnFetchInventory; | ||
13003 | |||
13004 | if (handlerFetchInventory != null) | ||
13005 | { | ||
13006 | OnFetchInventory(this, FetchInventoryx.InventoryData[i].ItemID, | ||
13007 | FetchInventoryx.InventoryData[i].OwnerID); | ||
13008 | } | ||
13009 | } | ||
13010 | } | ||
13011 | break; | ||
13012 | |||
13013 | case PacketType.FetchInventoryDescendents: | ||
13014 | FetchInventoryDescendentsPacket Fetch = (FetchInventoryDescendentsPacket)Pack; | ||
13015 | |||
13016 | #region Packet Session and User Check | ||
13017 | if (m_checkPackets) | ||
13018 | { | ||
13019 | if (Fetch.AgentData.SessionID != SessionId || | ||
13020 | Fetch.AgentData.AgentID != AgentId) | ||
13021 | break; | ||
13022 | } | ||
13023 | #endregion | ||
13024 | |||
13025 | FetchInventoryDescendents handlerFetchInventoryDescendents = OnFetchInventoryDescendents; | ||
13026 | if (handlerFetchInventoryDescendents != null) | ||
13027 | { | ||
13028 | handlerFetchInventoryDescendents(this, Fetch.InventoryData.FolderID, Fetch.InventoryData.OwnerID, | ||
13029 | Fetch.InventoryData.FetchFolders, Fetch.InventoryData.FetchItems, | ||
13030 | Fetch.InventoryData.SortOrder); | ||
13031 | } | ||
13032 | break; | ||
13033 | |||
13034 | case PacketType.PurgeInventoryDescendents: | ||
13035 | PurgeInventoryDescendentsPacket Purge = (PurgeInventoryDescendentsPacket)Pack; | ||
13036 | |||
13037 | #region Packet Session and User Check | ||
13038 | if (m_checkPackets) | ||
13039 | { | ||
13040 | if (Purge.AgentData.SessionID != SessionId || | ||
13041 | Purge.AgentData.AgentID != AgentId) | ||
13042 | break; | ||
13043 | } | ||
13044 | #endregion | ||
13045 | |||
13046 | PurgeInventoryDescendents handlerPurgeInventoryDescendents = OnPurgeInventoryDescendents; | ||
13047 | if (handlerPurgeInventoryDescendents != null) | ||
13048 | { | ||
13049 | handlerPurgeInventoryDescendents(this, Purge.InventoryData.FolderID); | ||
13050 | } | ||
13051 | break; | ||
13052 | |||
13053 | case PacketType.UpdateInventoryItem: | ||
13054 | UpdateInventoryItemPacket inventoryItemUpdate = (UpdateInventoryItemPacket)Pack; | ||
13055 | |||
13056 | #region Packet Session and User Check | ||
13057 | if (m_checkPackets) | ||
13058 | { | ||
13059 | if (inventoryItemUpdate.AgentData.SessionID != SessionId || | ||
13060 | inventoryItemUpdate.AgentData.AgentID != AgentId) | ||
13061 | break; | ||
13062 | } | ||
13063 | #endregion | ||
13064 | |||
13065 | if (OnUpdateInventoryItem != null) | ||
13066 | { | ||
13067 | UpdateInventoryItem handlerUpdateInventoryItem = null; | ||
13068 | for (int i = 0; i < inventoryItemUpdate.InventoryData.Length; i++) | ||
13069 | { | ||
13070 | handlerUpdateInventoryItem = OnUpdateInventoryItem; | ||
13071 | |||
13072 | if (handlerUpdateInventoryItem != null) | ||
13073 | { | ||
13074 | InventoryItemBase itemUpd = new InventoryItemBase(); | ||
13075 | itemUpd.ID = inventoryItemUpdate.InventoryData[i].ItemID; | ||
13076 | itemUpd.Name = Util.FieldToString(inventoryItemUpdate.InventoryData[i].Name); | ||
13077 | itemUpd.Description = Util.FieldToString(inventoryItemUpdate.InventoryData[i].Description); | ||
13078 | itemUpd.GroupID = inventoryItemUpdate.InventoryData[i].GroupID; | ||
13079 | itemUpd.GroupOwned = inventoryItemUpdate.InventoryData[i].GroupOwned; | ||
13080 | itemUpd.GroupPermissions = inventoryItemUpdate.InventoryData[i].GroupMask; | ||
13081 | itemUpd.NextPermissions = inventoryItemUpdate.InventoryData[i].NextOwnerMask; | ||
13082 | itemUpd.EveryOnePermissions = inventoryItemUpdate.InventoryData[i].EveryoneMask; | ||
13083 | itemUpd.CreationDate = inventoryItemUpdate.InventoryData[i].CreationDate; | ||
13084 | itemUpd.Folder = inventoryItemUpdate.InventoryData[i].FolderID; | ||
13085 | itemUpd.InvType = inventoryItemUpdate.InventoryData[i].InvType; | ||
13086 | itemUpd.SalePrice = inventoryItemUpdate.InventoryData[i].SalePrice; | ||
13087 | itemUpd.SaleType = inventoryItemUpdate.InventoryData[i].SaleType; | ||
13088 | itemUpd.Flags = inventoryItemUpdate.InventoryData[i].Flags; | ||
13089 | |||
13090 | OnUpdateInventoryItem(this, inventoryItemUpdate.InventoryData[i].TransactionID, | ||
13091 | inventoryItemUpdate.InventoryData[i].ItemID, | ||
13092 | itemUpd); | ||
13093 | } | ||
13094 | } | ||
13095 | } | ||
13096 | break; | ||
13097 | |||
13098 | case PacketType.CopyInventoryItem: | ||
13099 | CopyInventoryItemPacket copyitem = (CopyInventoryItemPacket)Pack; | ||
13100 | |||
13101 | #region Packet Session and User Check | ||
13102 | if (m_checkPackets) | ||
13103 | { | ||
13104 | if (copyitem.AgentData.SessionID != SessionId || | ||
13105 | copyitem.AgentData.AgentID != AgentId) | ||
13106 | break; | ||
13107 | } | ||
13108 | #endregion | ||
13109 | |||
13110 | CopyInventoryItem handlerCopyInventoryItem = null; | ||
13111 | if (OnCopyInventoryItem != null) | ||
13112 | { | ||
13113 | foreach (CopyInventoryItemPacket.InventoryDataBlock datablock in copyitem.InventoryData) | ||
13114 | { | ||
13115 | handlerCopyInventoryItem = OnCopyInventoryItem; | ||
13116 | if (handlerCopyInventoryItem != null) | ||
13117 | { | ||
13118 | handlerCopyInventoryItem(this, datablock.CallbackID, datablock.OldAgentID, | ||
13119 | datablock.OldItemID, datablock.NewFolderID, | ||
13120 | Util.FieldToString(datablock.NewName)); | ||
13121 | } | ||
13122 | } | ||
13123 | } | ||
13124 | break; | ||
13125 | |||
13126 | case PacketType.MoveInventoryItem: | ||
13127 | MoveInventoryItemPacket moveitem = (MoveInventoryItemPacket)Pack; | ||
13128 | |||
13129 | #region Packet Session and User Check | ||
13130 | if (m_checkPackets) | ||
13131 | { | ||
13132 | if (moveitem.AgentData.SessionID != SessionId || | ||
13133 | moveitem.AgentData.AgentID != AgentId) | ||
13134 | break; | ||
13135 | } | ||
13136 | #endregion | ||
13137 | |||
13138 | if (OnMoveInventoryItem != null) | ||
13139 | { | ||
13140 | MoveInventoryItem handlerMoveInventoryItem = null; | ||
13141 | InventoryItemBase itm = null; | ||
13142 | List<InventoryItemBase> items = new List<InventoryItemBase>(); | ||
13143 | foreach (MoveInventoryItemPacket.InventoryDataBlock datablock in moveitem.InventoryData) | ||
13144 | { | ||
13145 | itm = new InventoryItemBase(datablock.ItemID, AgentId); | ||
13146 | itm.Folder = datablock.FolderID; | ||
13147 | itm.Name = Util.FieldToString(datablock.NewName); | ||
13148 | // weird, comes out as empty string | ||
13149 | //m_log.DebugFormat("[XXX] new name: {0}", itm.Name); | ||
13150 | items.Add(itm); | ||
13151 | } | ||
13152 | handlerMoveInventoryItem = OnMoveInventoryItem; | ||
13153 | if (handlerMoveInventoryItem != null) | ||
13154 | { | ||
13155 | handlerMoveInventoryItem(this, items); | ||
13156 | } | ||
13157 | } | ||
13158 | break; | ||
13159 | |||
13160 | case PacketType.RemoveInventoryItem: | ||
13161 | RemoveInventoryItemPacket removeItem = (RemoveInventoryItemPacket)Pack; | ||
13162 | |||
13163 | #region Packet Session and User Check | ||
13164 | if (m_checkPackets) | ||
13165 | { | ||
13166 | if (removeItem.AgentData.SessionID != SessionId || | ||
13167 | removeItem.AgentData.AgentID != AgentId) | ||
13168 | break; | ||
13169 | } | ||
13170 | #endregion | ||
13171 | |||
13172 | if (OnRemoveInventoryItem != null) | ||
13173 | { | ||
13174 | RemoveInventoryItem handlerRemoveInventoryItem = null; | ||
13175 | List<UUID> uuids = new List<UUID>(); | ||
13176 | foreach (RemoveInventoryItemPacket.InventoryDataBlock datablock in removeItem.InventoryData) | ||
13177 | { | ||
13178 | uuids.Add(datablock.ItemID); | ||
13179 | } | ||
13180 | handlerRemoveInventoryItem = OnRemoveInventoryItem; | ||
13181 | if (handlerRemoveInventoryItem != null) | ||
13182 | { | ||
13183 | handlerRemoveInventoryItem(this, uuids); | ||
13184 | } | ||
13185 | |||
13186 | } | ||
13187 | break; | ||
13188 | |||
13189 | case PacketType.RemoveInventoryFolder: | ||
13190 | RemoveInventoryFolderPacket removeFolder = (RemoveInventoryFolderPacket)Pack; | ||
13191 | |||
13192 | #region Packet Session and User Check | ||
13193 | if (m_checkPackets) | ||
13194 | { | ||
13195 | if (removeFolder.AgentData.SessionID != SessionId || | ||
13196 | removeFolder.AgentData.AgentID != AgentId) | ||
13197 | break; | ||
13198 | } | ||
13199 | #endregion | ||
13200 | |||
13201 | if (OnRemoveInventoryFolder != null) | ||
13202 | { | ||
13203 | RemoveInventoryFolder handlerRemoveInventoryFolder = null; | ||
13204 | List<UUID> uuids = new List<UUID>(); | ||
13205 | foreach (RemoveInventoryFolderPacket.FolderDataBlock datablock in removeFolder.FolderData) | ||
13206 | { | ||
13207 | uuids.Add(datablock.FolderID); | ||
13208 | } | ||
13209 | handlerRemoveInventoryFolder = OnRemoveInventoryFolder; | ||
13210 | if (handlerRemoveInventoryFolder != null) | ||
13211 | { | ||
13212 | handlerRemoveInventoryFolder(this, uuids); | ||
13213 | } | ||
13214 | } | ||
13215 | break; | ||
13216 | |||
13217 | case PacketType.RemoveInventoryObjects: | ||
13218 | RemoveInventoryObjectsPacket removeObject = (RemoveInventoryObjectsPacket)Pack; | ||
13219 | #region Packet Session and User Check | ||
13220 | if (m_checkPackets) | ||
13221 | { | ||
13222 | if (removeObject.AgentData.SessionID != SessionId || | ||
13223 | removeObject.AgentData.AgentID != AgentId) | ||
13224 | break; | ||
13225 | } | ||
13226 | #endregion | ||
13227 | if (OnRemoveInventoryFolder != null) | ||
13228 | { | ||
13229 | RemoveInventoryFolder handlerRemoveInventoryFolder = null; | ||
13230 | List<UUID> uuids = new List<UUID>(); | ||
13231 | foreach (RemoveInventoryObjectsPacket.FolderDataBlock datablock in removeObject.FolderData) | ||
13232 | { | ||
13233 | uuids.Add(datablock.FolderID); | ||
13234 | } | ||
13235 | handlerRemoveInventoryFolder = OnRemoveInventoryFolder; | ||
13236 | if (handlerRemoveInventoryFolder != null) | ||
13237 | { | ||
13238 | handlerRemoveInventoryFolder(this, uuids); | ||
13239 | } | ||
13240 | } | ||
13241 | |||
13242 | if (OnRemoveInventoryItem != null) | ||
13243 | { | ||
13244 | RemoveInventoryItem handlerRemoveInventoryItem = null; | ||
13245 | List<UUID> uuids = new List<UUID>(); | ||
13246 | foreach (RemoveInventoryObjectsPacket.ItemDataBlock datablock in removeObject.ItemData) | ||
13247 | { | ||
13248 | uuids.Add(datablock.ItemID); | ||
13249 | } | ||
13250 | handlerRemoveInventoryItem = OnRemoveInventoryItem; | ||
13251 | if (handlerRemoveInventoryItem != null) | ||
13252 | { | ||
13253 | handlerRemoveInventoryItem(this, uuids); | ||
13254 | } | ||
13255 | } | ||
13256 | break; | ||
13257 | |||
13258 | case PacketType.RequestTaskInventory: | ||
13259 | RequestTaskInventoryPacket requesttask = (RequestTaskInventoryPacket)Pack; | ||
13260 | |||
13261 | #region Packet Session and User Check | ||
13262 | if (m_checkPackets) | ||
13263 | { | ||
13264 | if (requesttask.AgentData.SessionID != SessionId || | ||
13265 | requesttask.AgentData.AgentID != AgentId) | ||
13266 | break; | ||
13267 | } | ||
13268 | #endregion | ||
13269 | |||
13270 | RequestTaskInventory handlerRequestTaskInventory = OnRequestTaskInventory; | ||
13271 | if (handlerRequestTaskInventory != null) | ||
13272 | { | ||
13273 | handlerRequestTaskInventory(this, requesttask.InventoryData.LocalID); | ||
13274 | } | ||
13275 | break; | ||
13276 | |||
13277 | case PacketType.UpdateTaskInventory: | ||
13278 | UpdateTaskInventoryPacket updatetask = (UpdateTaskInventoryPacket)Pack; | ||
13279 | |||
13280 | #region Packet Session and User Check | ||
13281 | if (m_checkPackets) | ||
13282 | { | ||
13283 | if (updatetask.AgentData.SessionID != SessionId || | ||
13284 | updatetask.AgentData.AgentID != AgentId) | ||
13285 | break; | ||
13286 | } | ||
13287 | #endregion | ||
13288 | |||
13289 | if (OnUpdateTaskInventory != null) | ||
13290 | { | ||
13291 | if (updatetask.UpdateData.Key == 0) | ||
13292 | { | ||
13293 | UpdateTaskInventory handlerUpdateTaskInventory = OnUpdateTaskInventory; | ||
13294 | if (handlerUpdateTaskInventory != null) | ||
13295 | { | ||
13296 | TaskInventoryItem newTaskItem = new TaskInventoryItem(); | ||
13297 | newTaskItem.ItemID = updatetask.InventoryData.ItemID; | ||
13298 | newTaskItem.ParentID = updatetask.InventoryData.FolderID; | ||
13299 | newTaskItem.CreatorID = updatetask.InventoryData.CreatorID; | ||
13300 | newTaskItem.OwnerID = updatetask.InventoryData.OwnerID; | ||
13301 | newTaskItem.GroupID = updatetask.InventoryData.GroupID; | ||
13302 | newTaskItem.BasePermissions = updatetask.InventoryData.BaseMask; | ||
13303 | newTaskItem.CurrentPermissions = updatetask.InventoryData.OwnerMask; | ||
13304 | newTaskItem.GroupPermissions = updatetask.InventoryData.GroupMask; | ||
13305 | newTaskItem.EveryonePermissions = updatetask.InventoryData.EveryoneMask; | ||
13306 | newTaskItem.NextPermissions = updatetask.InventoryData.NextOwnerMask; | ||
13307 | //newTaskItem.GroupOwned=updatetask.InventoryData.GroupOwned; | ||
13308 | newTaskItem.Type = updatetask.InventoryData.Type; | ||
13309 | newTaskItem.InvType = updatetask.InventoryData.InvType; | ||
13310 | newTaskItem.Flags = updatetask.InventoryData.Flags; | ||
13311 | //newTaskItem.SaleType=updatetask.InventoryData.SaleType; | ||
13312 | //newTaskItem.SalePrice=updatetask.InventoryData.SalePrice;; | ||
13313 | newTaskItem.Name = Util.FieldToString(updatetask.InventoryData.Name); | ||
13314 | newTaskItem.Description = Util.FieldToString(updatetask.InventoryData.Description); | ||
13315 | newTaskItem.CreationDate = (uint)updatetask.InventoryData.CreationDate; | ||
13316 | handlerUpdateTaskInventory(this, updatetask.InventoryData.TransactionID, | ||
13317 | newTaskItem, updatetask.UpdateData.LocalID); | ||
13318 | } | ||
13319 | } | ||
13320 | } | ||
13321 | |||
13322 | break; | ||
13323 | |||
13324 | case PacketType.RemoveTaskInventory: | ||
13325 | |||
13326 | RemoveTaskInventoryPacket removeTask = (RemoveTaskInventoryPacket)Pack; | ||
13327 | |||
13328 | #region Packet Session and User Check | ||
13329 | if (m_checkPackets) | ||
13330 | { | ||
13331 | if (removeTask.AgentData.SessionID != SessionId || | ||
13332 | removeTask.AgentData.AgentID != AgentId) | ||
13333 | break; | ||
13334 | } | ||
13335 | #endregion | ||
13336 | |||
13337 | RemoveTaskInventory handlerRemoveTaskItem = OnRemoveTaskItem; | ||
13338 | |||
13339 | if (handlerRemoveTaskItem != null) | ||
13340 | { | ||
13341 | handlerRemoveTaskItem(this, removeTask.InventoryData.ItemID, removeTask.InventoryData.LocalID); | ||
13342 | } | ||
13343 | |||
13344 | break; | ||
13345 | |||
13346 | case PacketType.MoveTaskInventory: | ||
13347 | |||
13348 | MoveTaskInventoryPacket moveTaskInventoryPacket = (MoveTaskInventoryPacket)Pack; | ||
13349 | |||
13350 | #region Packet Session and User Check | ||
13351 | if (m_checkPackets) | ||
13352 | { | ||
13353 | if (moveTaskInventoryPacket.AgentData.SessionID != SessionId || | ||
13354 | moveTaskInventoryPacket.AgentData.AgentID != AgentId) | ||
13355 | break; | ||
13356 | } | ||
13357 | #endregion | ||
13358 | |||
13359 | MoveTaskInventory handlerMoveTaskItem = OnMoveTaskItem; | ||
13360 | |||
13361 | if (handlerMoveTaskItem != null) | ||
13362 | { | ||
13363 | handlerMoveTaskItem( | ||
13364 | this, moveTaskInventoryPacket.AgentData.FolderID, | ||
13365 | moveTaskInventoryPacket.InventoryData.LocalID, | ||
13366 | moveTaskInventoryPacket.InventoryData.ItemID); | ||
13367 | } | ||
13368 | |||
13369 | break; | ||
13370 | |||
13371 | case PacketType.RezScript: | ||
13372 | //m_log.Debug(Pack.ToString()); | ||
13373 | RezScriptPacket rezScriptx = (RezScriptPacket)Pack; | ||
13374 | |||
13375 | #region Packet Session and User Check | ||
13376 | if (m_checkPackets) | ||
13377 | { | ||
13378 | if (rezScriptx.AgentData.SessionID != SessionId || | ||
13379 | rezScriptx.AgentData.AgentID != AgentId) | ||
13380 | break; | ||
13381 | } | ||
13382 | #endregion | ||
13383 | |||
13384 | RezScript handlerRezScript = OnRezScript; | ||
13385 | InventoryItemBase item = new InventoryItemBase(); | ||
13386 | item.ID = rezScriptx.InventoryBlock.ItemID; | ||
13387 | item.Folder = rezScriptx.InventoryBlock.FolderID; | ||
13388 | item.CreatorId = rezScriptx.InventoryBlock.CreatorID.ToString(); | ||
13389 | item.Owner = rezScriptx.InventoryBlock.OwnerID; | ||
13390 | item.BasePermissions = rezScriptx.InventoryBlock.BaseMask; | ||
13391 | item.CurrentPermissions = rezScriptx.InventoryBlock.OwnerMask; | ||
13392 | item.EveryOnePermissions = rezScriptx.InventoryBlock.EveryoneMask; | ||
13393 | item.NextPermissions = rezScriptx.InventoryBlock.NextOwnerMask; | ||
13394 | item.GroupPermissions = rezScriptx.InventoryBlock.GroupMask; | ||
13395 | item.GroupOwned = rezScriptx.InventoryBlock.GroupOwned; | ||
13396 | item.GroupID = rezScriptx.InventoryBlock.GroupID; | ||
13397 | item.AssetType = rezScriptx.InventoryBlock.Type; | ||
13398 | item.InvType = rezScriptx.InventoryBlock.InvType; | ||
13399 | item.Flags = rezScriptx.InventoryBlock.Flags; | ||
13400 | item.SaleType = rezScriptx.InventoryBlock.SaleType; | ||
13401 | item.SalePrice = rezScriptx.InventoryBlock.SalePrice; | ||
13402 | item.Name = Util.FieldToString(rezScriptx.InventoryBlock.Name); | ||
13403 | item.Description = Util.FieldToString(rezScriptx.InventoryBlock.Description); | ||
13404 | item.CreationDate = rezScriptx.InventoryBlock.CreationDate; | ||
13405 | |||
13406 | if (handlerRezScript != null) | ||
13407 | { | ||
13408 | handlerRezScript(this, item, rezScriptx.InventoryBlock.TransactionID, rezScriptx.UpdateBlock.ObjectLocalID); | ||
13409 | } | ||
13410 | break; | ||
13411 | |||
13412 | case PacketType.MapLayerRequest: | ||
13413 | RequestMapLayer(); | ||
13414 | break; | ||
13415 | case PacketType.MapBlockRequest: | ||
13416 | MapBlockRequestPacket MapRequest = (MapBlockRequestPacket)Pack; | ||
13417 | |||
13418 | #region Packet Session and User Check | ||
13419 | if (m_checkPackets) | ||
13420 | { | ||
13421 | if (MapRequest.AgentData.SessionID != SessionId || | ||
13422 | MapRequest.AgentData.AgentID != AgentId) | ||
13423 | break; | ||
13424 | } | ||
13425 | #endregion | ||
13426 | |||
13427 | RequestMapBlocks handlerRequestMapBlocks = OnRequestMapBlocks; | ||
13428 | if (handlerRequestMapBlocks != null) | ||
13429 | { | ||
13430 | handlerRequestMapBlocks(this, MapRequest.PositionData.MinX, MapRequest.PositionData.MinY, | ||
13431 | MapRequest.PositionData.MaxX, MapRequest.PositionData.MaxY, MapRequest.AgentData.Flags); | ||
13432 | } | ||
13433 | break; | ||
13434 | case PacketType.MapNameRequest: | ||
13435 | MapNameRequestPacket map = (MapNameRequestPacket)Pack; | ||
13436 | |||
13437 | #region Packet Session and User Check | ||
13438 | if (m_checkPackets) | ||
13439 | { | ||
13440 | if (map.AgentData.SessionID != SessionId || | ||
13441 | map.AgentData.AgentID != AgentId) | ||
13442 | break; | ||
13443 | } | ||
13444 | #endregion | ||
13445 | |||
13446 | string mapName = Util.UTF8.GetString(map.NameData.Name, 0, | ||
13447 | map.NameData.Name.Length - 1); | ||
13448 | RequestMapName handlerMapNameRequest = OnMapNameRequest; | ||
13449 | if (handlerMapNameRequest != null) | ||
13450 | { | ||
13451 | handlerMapNameRequest(this, mapName); | ||
13452 | } | ||
13453 | break; | ||
13454 | |||
13455 | case PacketType.TeleportLandmarkRequest: | ||
13456 | TeleportLandmarkRequestPacket tpReq = (TeleportLandmarkRequestPacket)Pack; | ||
13457 | |||
13458 | #region Packet Session and User Check | ||
13459 | if (m_checkPackets) | ||
13460 | { | ||
13461 | if (tpReq.Info.SessionID != SessionId || | ||
13462 | tpReq.Info.AgentID != AgentId) | ||
13463 | break; | ||
13464 | } | ||
13465 | #endregion | ||
13466 | |||
13467 | UUID lmid = tpReq.Info.LandmarkID; | ||
13468 | AssetLandmark lm; | ||
13469 | if (lmid != UUID.Zero) | ||
13470 | { | ||
13471 | //AssetBase lma = m_assetCache.GetAsset(lmid, false); | ||
13472 | AssetBase lma = m_assetService.Get(lmid.ToString()); | ||
13473 | |||
13474 | if (lma == null) | ||
13475 | { | ||
13476 | // Failed to find landmark | ||
13477 | TeleportCancelPacket tpCancel = (TeleportCancelPacket)PacketPool.Instance.GetPacket(PacketType.TeleportCancel); | ||
13478 | tpCancel.Info.SessionID = tpReq.Info.SessionID; | ||
13479 | tpCancel.Info.AgentID = tpReq.Info.AgentID; | ||
13480 | OutPacket(tpCancel, ThrottleOutPacketType.Task); | ||
13481 | } | ||
13482 | |||
13483 | try | ||
13484 | { | ||
13485 | lm = new AssetLandmark(lma); | ||
13486 | } | ||
13487 | catch (NullReferenceException) | ||
13488 | { | ||
13489 | // asset not found generates null ref inside the assetlandmark constructor. | ||
13490 | TeleportCancelPacket tpCancel = (TeleportCancelPacket)PacketPool.Instance.GetPacket(PacketType.TeleportCancel); | ||
13491 | tpCancel.Info.SessionID = tpReq.Info.SessionID; | ||
13492 | tpCancel.Info.AgentID = tpReq.Info.AgentID; | ||
13493 | OutPacket(tpCancel, ThrottleOutPacketType.Task); | ||
13494 | break; | ||
13495 | } | ||
13496 | } | ||
13497 | else | ||
13498 | { | ||
13499 | // Teleport home request | ||
13500 | UUIDNameRequest handlerTeleportHomeRequest = OnTeleportHomeRequest; | ||
13501 | if (handlerTeleportHomeRequest != null) | ||
13502 | { | ||
13503 | handlerTeleportHomeRequest(AgentId, this); | ||
13504 | } | ||
13505 | break; | ||
13506 | } | ||
13507 | |||
13508 | TeleportLandmarkRequest handlerTeleportLandmarkRequest = OnTeleportLandmarkRequest; | ||
13509 | if (handlerTeleportLandmarkRequest != null) | ||
13510 | { | ||
13511 | handlerTeleportLandmarkRequest(this, lm.RegionID, lm.Position); | ||
13512 | } | ||
13513 | else | ||
13514 | { | ||
13515 | //no event handler so cancel request | ||
13516 | |||
13517 | |||
13518 | TeleportCancelPacket tpCancel = (TeleportCancelPacket)PacketPool.Instance.GetPacket(PacketType.TeleportCancel); | ||
13519 | tpCancel.Info.AgentID = tpReq.Info.AgentID; | ||
13520 | tpCancel.Info.SessionID = tpReq.Info.SessionID; | ||
13521 | OutPacket(tpCancel, ThrottleOutPacketType.Task); | ||
13522 | |||
13523 | } | ||
13524 | break; | ||
13525 | |||
13526 | case PacketType.TeleportLocationRequest: | ||
13527 | TeleportLocationRequestPacket tpLocReq = (TeleportLocationRequestPacket)Pack; | ||
13528 | // m_log.Debug(tpLocReq.ToString()); | ||
13529 | |||
13530 | #region Packet Session and User Check | ||
13531 | if (m_checkPackets) | ||
13532 | { | ||
13533 | if (tpLocReq.AgentData.SessionID != SessionId || | ||
13534 | tpLocReq.AgentData.AgentID != AgentId) | ||
13535 | break; | ||
13536 | } | ||
13537 | #endregion | ||
13538 | |||
13539 | TeleportLocationRequest handlerTeleportLocationRequest = OnTeleportLocationRequest; | ||
13540 | if (handlerTeleportLocationRequest != null) | ||
13541 | { | ||
13542 | handlerTeleportLocationRequest(this, tpLocReq.Info.RegionHandle, tpLocReq.Info.Position, | ||
13543 | tpLocReq.Info.LookAt, 16); | ||
13544 | } | ||
13545 | else | ||
13546 | { | ||
13547 | //no event handler so cancel request | ||
13548 | TeleportCancelPacket tpCancel = (TeleportCancelPacket)PacketPool.Instance.GetPacket(PacketType.TeleportCancel); | ||
13549 | tpCancel.Info.SessionID = tpLocReq.AgentData.SessionID; | ||
13550 | tpCancel.Info.AgentID = tpLocReq.AgentData.AgentID; | ||
13551 | OutPacket(tpCancel, ThrottleOutPacketType.Task); | ||
13552 | } | ||
13553 | break; | ||
13554 | |||
13555 | //#endregion | ||
13556 | |||
13557 | case PacketType.UUIDNameRequest: | ||
13558 | UUIDNameRequestPacket incoming = (UUIDNameRequestPacket)Pack; | ||
13559 | |||
13560 | foreach (UUIDNameRequestPacket.UUIDNameBlockBlock UUIDBlock in incoming.UUIDNameBlock) | ||
13561 | { | ||
13562 | UUIDNameRequest handlerNameRequest = OnNameFromUUIDRequest; | ||
13563 | if (handlerNameRequest != null) | ||
13564 | { | ||
13565 | handlerNameRequest(UUIDBlock.ID, this); | ||
13566 | } | ||
13567 | } | ||
13568 | break; | ||
13569 | |||
13570 | //#region Parcel related packets | ||
13571 | |||
13572 | |||
13573 | case PacketType.RegionHandleRequest: | ||
13574 | RegionHandleRequestPacket rhrPack = (RegionHandleRequestPacket)Pack; | ||
13575 | |||
13576 | RegionHandleRequest handlerRegionHandleRequest = OnRegionHandleRequest; | ||
13577 | if (handlerRegionHandleRequest != null) | ||
13578 | { | ||
13579 | handlerRegionHandleRequest(this, rhrPack.RequestBlock.RegionID); | ||
13580 | } | ||
13581 | break; | ||
13582 | |||
13583 | case PacketType.ParcelInfoRequest: | ||
13584 | ParcelInfoRequestPacket pirPack = (ParcelInfoRequestPacket)Pack; | ||
13585 | |||
13586 | #region Packet Session and User Check | ||
13587 | if (m_checkPackets) | ||
13588 | { | ||
13589 | if (pirPack.AgentData.SessionID != SessionId || | ||
13590 | pirPack.AgentData.AgentID != AgentId) | ||
13591 | break; | ||
13592 | } | ||
13593 | #endregion | ||
13594 | |||
13595 | ParcelInfoRequest handlerParcelInfoRequest = OnParcelInfoRequest; | ||
13596 | if (handlerParcelInfoRequest != null) | ||
13597 | { | ||
13598 | handlerParcelInfoRequest(this, pirPack.Data.ParcelID); | ||
13599 | } | ||
13600 | break; | ||
13601 | |||
13602 | case PacketType.ParcelAccessListRequest: | ||
13603 | ParcelAccessListRequestPacket requestPacket = (ParcelAccessListRequestPacket)Pack; | ||
13604 | |||
13605 | #region Packet Session and User Check | ||
13606 | if (m_checkPackets) | ||
13607 | { | ||
13608 | if (requestPacket.AgentData.SessionID != SessionId || | ||
13609 | requestPacket.AgentData.AgentID != AgentId) | ||
13610 | break; | ||
13611 | } | ||
13612 | #endregion | ||
13613 | |||
13614 | ParcelAccessListRequest handlerParcelAccessListRequest = OnParcelAccessListRequest; | ||
13615 | |||
13616 | if (handlerParcelAccessListRequest != null) | ||
13617 | { | ||
13618 | handlerParcelAccessListRequest(requestPacket.AgentData.AgentID, requestPacket.AgentData.SessionID, | ||
13619 | requestPacket.Data.Flags, requestPacket.Data.SequenceID, | ||
13620 | requestPacket.Data.LocalID, this); | ||
13621 | } | ||
13622 | break; | ||
13623 | |||
13624 | case PacketType.ParcelAccessListUpdate: | ||
13625 | ParcelAccessListUpdatePacket updatePacket = (ParcelAccessListUpdatePacket)Pack; | ||
13626 | |||
13627 | #region Packet Session and User Check | ||
13628 | if (m_checkPackets) | ||
13629 | { | ||
13630 | if (updatePacket.AgentData.SessionID != SessionId || | ||
13631 | updatePacket.AgentData.AgentID != AgentId) | ||
13632 | break; | ||
13633 | } | ||
13634 | #endregion | ||
13635 | |||
13636 | List<ParcelManager.ParcelAccessEntry> entries = new List<ParcelManager.ParcelAccessEntry>(); | ||
13637 | foreach (ParcelAccessListUpdatePacket.ListBlock block in updatePacket.List) | ||
13638 | { | ||
13639 | ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry(); | ||
13640 | entry.AgentID = block.ID; | ||
13641 | entry.Flags = (AccessList)block.Flags; | ||
13642 | entry.Time = new DateTime(); | ||
13643 | entries.Add(entry); | ||
13644 | } | ||
13645 | |||
13646 | ParcelAccessListUpdateRequest handlerParcelAccessListUpdateRequest = OnParcelAccessListUpdateRequest; | ||
13647 | if (handlerParcelAccessListUpdateRequest != null) | ||
13648 | { | ||
13649 | handlerParcelAccessListUpdateRequest(updatePacket.AgentData.AgentID, | ||
13650 | updatePacket.AgentData.SessionID, updatePacket.Data.Flags, | ||
13651 | updatePacket.Data.LocalID, entries, this); | ||
13652 | } | ||
13653 | break; | ||
13654 | |||
13655 | case PacketType.ParcelPropertiesRequest: | ||
13656 | |||
13657 | ParcelPropertiesRequestPacket propertiesRequest = (ParcelPropertiesRequestPacket)Pack; | ||
13658 | |||
13659 | #region Packet Session and User Check | ||
13660 | if (m_checkPackets) | ||
13661 | { | ||
13662 | if (propertiesRequest.AgentData.SessionID != SessionId || | ||
13663 | propertiesRequest.AgentData.AgentID != AgentId) | ||
13664 | break; | ||
13665 | } | ||
13666 | #endregion | ||
13667 | |||
13668 | ParcelPropertiesRequest handlerParcelPropertiesRequest = OnParcelPropertiesRequest; | ||
13669 | if (handlerParcelPropertiesRequest != null) | ||
13670 | { | ||
13671 | handlerParcelPropertiesRequest((int)Math.Round(propertiesRequest.ParcelData.West), | ||
13672 | (int)Math.Round(propertiesRequest.ParcelData.South), | ||
13673 | (int)Math.Round(propertiesRequest.ParcelData.East), | ||
13674 | (int)Math.Round(propertiesRequest.ParcelData.North), | ||
13675 | propertiesRequest.ParcelData.SequenceID, | ||
13676 | propertiesRequest.ParcelData.SnapSelection, this); | ||
13677 | } | ||
13678 | break; | ||
13679 | |||
13680 | case PacketType.ParcelDivide: | ||
13681 | ParcelDividePacket landDivide = (ParcelDividePacket)Pack; | ||
13682 | |||
13683 | #region Packet Session and User Check | ||
13684 | if (m_checkPackets) | ||
13685 | { | ||
13686 | if (landDivide.AgentData.SessionID != SessionId || | ||
13687 | landDivide.AgentData.AgentID != AgentId) | ||
13688 | break; | ||
13689 | } | ||
13690 | #endregion | ||
13691 | |||
13692 | ParcelDivideRequest handlerParcelDivideRequest = OnParcelDivideRequest; | ||
13693 | if (handlerParcelDivideRequest != null) | ||
13694 | { | ||
13695 | handlerParcelDivideRequest((int)Math.Round(landDivide.ParcelData.West), | ||
13696 | (int)Math.Round(landDivide.ParcelData.South), | ||
13697 | (int)Math.Round(landDivide.ParcelData.East), | ||
13698 | (int)Math.Round(landDivide.ParcelData.North), this); | ||
13699 | } | ||
13700 | break; | ||
13701 | |||
13702 | case PacketType.ParcelJoin: | ||
13703 | ParcelJoinPacket landJoin = (ParcelJoinPacket)Pack; | ||
13704 | |||
13705 | #region Packet Session and User Check | ||
13706 | if (m_checkPackets) | ||
13707 | { | ||
13708 | if (landJoin.AgentData.SessionID != SessionId || | ||
13709 | landJoin.AgentData.AgentID != AgentId) | ||
13710 | break; | ||
13711 | } | ||
13712 | #endregion | ||
13713 | |||
13714 | ParcelJoinRequest handlerParcelJoinRequest = OnParcelJoinRequest; | ||
13715 | |||
13716 | if (handlerParcelJoinRequest != null) | ||
13717 | { | ||
13718 | handlerParcelJoinRequest((int)Math.Round(landJoin.ParcelData.West), | ||
13719 | (int)Math.Round(landJoin.ParcelData.South), | ||
13720 | (int)Math.Round(landJoin.ParcelData.East), | ||
13721 | (int)Math.Round(landJoin.ParcelData.North), this); | ||
13722 | } | ||
13723 | break; | ||
13724 | |||
13725 | case PacketType.ParcelPropertiesUpdate: | ||
13726 | ParcelPropertiesUpdatePacket parcelPropertiesPacket = (ParcelPropertiesUpdatePacket)Pack; | ||
13727 | |||
13728 | #region Packet Session and User Check | ||
13729 | if (m_checkPackets) | ||
13730 | { | ||
13731 | if (parcelPropertiesPacket.AgentData.SessionID != SessionId || | ||
13732 | parcelPropertiesPacket.AgentData.AgentID != AgentId) | ||
13733 | break; | ||
13734 | } | ||
13735 | #endregion | ||
13736 | |||
13737 | ParcelPropertiesUpdateRequest handlerParcelPropertiesUpdateRequest = OnParcelPropertiesUpdateRequest; | ||
13738 | |||
13739 | if (handlerParcelPropertiesUpdateRequest != null) | ||
13740 | { | ||
13741 | LandUpdateArgs args = new LandUpdateArgs(); | ||
13742 | |||
13743 | args.AuthBuyerID = parcelPropertiesPacket.ParcelData.AuthBuyerID; | ||
13744 | args.Category = (ParcelCategory)parcelPropertiesPacket.ParcelData.Category; | ||
13745 | args.Desc = Utils.BytesToString(parcelPropertiesPacket.ParcelData.Desc); | ||
13746 | args.GroupID = parcelPropertiesPacket.ParcelData.GroupID; | ||
13747 | args.LandingType = parcelPropertiesPacket.ParcelData.LandingType; | ||
13748 | args.MediaAutoScale = parcelPropertiesPacket.ParcelData.MediaAutoScale; | ||
13749 | args.MediaID = parcelPropertiesPacket.ParcelData.MediaID; | ||
13750 | args.MediaURL = Utils.BytesToString(parcelPropertiesPacket.ParcelData.MediaURL); | ||
13751 | args.MusicURL = Utils.BytesToString(parcelPropertiesPacket.ParcelData.MusicURL); | ||
13752 | args.Name = Utils.BytesToString(parcelPropertiesPacket.ParcelData.Name); | ||
13753 | args.ParcelFlags = parcelPropertiesPacket.ParcelData.ParcelFlags; | ||
13754 | args.PassHours = parcelPropertiesPacket.ParcelData.PassHours; | ||
13755 | args.PassPrice = parcelPropertiesPacket.ParcelData.PassPrice; | ||
13756 | args.SalePrice = parcelPropertiesPacket.ParcelData.SalePrice; | ||
13757 | args.SnapshotID = parcelPropertiesPacket.ParcelData.SnapshotID; | ||
13758 | args.UserLocation = parcelPropertiesPacket.ParcelData.UserLocation; | ||
13759 | args.UserLookAt = parcelPropertiesPacket.ParcelData.UserLookAt; | ||
13760 | handlerParcelPropertiesUpdateRequest(args, parcelPropertiesPacket.ParcelData.LocalID, this); | ||
13761 | } | ||
13762 | break; | ||
13763 | |||
13764 | case PacketType.ParcelSelectObjects: | ||
13765 | ParcelSelectObjectsPacket selectPacket = (ParcelSelectObjectsPacket)Pack; | ||
13766 | |||
13767 | #region Packet Session and User Check | ||
13768 | if (m_checkPackets) | ||
13769 | { | ||
13770 | if (selectPacket.AgentData.SessionID != SessionId || | ||
13771 | selectPacket.AgentData.AgentID != AgentId) | ||
13772 | break; | ||
13773 | } | ||
13774 | #endregion | ||
13775 | |||
13776 | List<UUID> returnIDs = new List<UUID>(); | ||
13777 | |||
13778 | foreach (ParcelSelectObjectsPacket.ReturnIDsBlock rb in | ||
13779 | selectPacket.ReturnIDs) | ||
13780 | { | ||
13781 | returnIDs.Add(rb.ReturnID); | ||
13782 | } | ||
13783 | |||
13784 | ParcelSelectObjects handlerParcelSelectObjects = OnParcelSelectObjects; | ||
13785 | |||
13786 | if (handlerParcelSelectObjects != null) | ||
13787 | { | ||
13788 | handlerParcelSelectObjects(selectPacket.ParcelData.LocalID, | ||
13789 | Convert.ToInt32(selectPacket.ParcelData.ReturnType), returnIDs, this); | ||
13790 | } | ||
13791 | break; | ||
13792 | |||
13793 | case PacketType.ParcelObjectOwnersRequest: | ||
13794 | //m_log.Debug(Pack.ToString()); | ||
13795 | ParcelObjectOwnersRequestPacket reqPacket = (ParcelObjectOwnersRequestPacket)Pack; | ||
13796 | |||
13797 | #region Packet Session and User Check | ||
13798 | if (m_checkPackets) | ||
13799 | { | ||
13800 | if (reqPacket.AgentData.SessionID != SessionId || | ||
13801 | reqPacket.AgentData.AgentID != AgentId) | ||
13802 | break; | ||
13803 | } | ||
13804 | #endregion | ||
13805 | |||
13806 | ParcelObjectOwnerRequest handlerParcelObjectOwnerRequest = OnParcelObjectOwnerRequest; | ||
13807 | |||
13808 | if (handlerParcelObjectOwnerRequest != null) | ||
13809 | { | ||
13810 | handlerParcelObjectOwnerRequest(reqPacket.ParcelData.LocalID, this); | ||
13811 | } | ||
13812 | break; | ||
13813 | |||
13814 | case PacketType.ParcelGodForceOwner: | ||
13815 | ParcelGodForceOwnerPacket godForceOwnerPacket = (ParcelGodForceOwnerPacket)Pack; | ||
13816 | |||
13817 | #region Packet Session and User Check | ||
13818 | if (m_checkPackets) | ||
13819 | { | ||
13820 | if (godForceOwnerPacket.AgentData.SessionID != SessionId || | ||
13821 | godForceOwnerPacket.AgentData.AgentID != AgentId) | ||
13822 | break; | ||
13823 | } | ||
13824 | #endregion | ||
13825 | |||
13826 | ParcelGodForceOwner handlerParcelGodForceOwner = OnParcelGodForceOwner; | ||
13827 | if (handlerParcelGodForceOwner != null) | ||
13828 | { | ||
13829 | handlerParcelGodForceOwner(godForceOwnerPacket.Data.LocalID, godForceOwnerPacket.Data.OwnerID, this); | ||
13830 | } | ||
13831 | break; | ||
13832 | |||
13833 | case PacketType.ParcelRelease: | ||
13834 | ParcelReleasePacket releasePacket = (ParcelReleasePacket)Pack; | ||
13835 | |||
13836 | #region Packet Session and User Check | ||
13837 | if (m_checkPackets) | ||
13838 | { | ||
13839 | if (releasePacket.AgentData.SessionID != SessionId || | ||
13840 | releasePacket.AgentData.AgentID != AgentId) | ||
13841 | break; | ||
13842 | } | ||
13843 | #endregion | ||
13844 | |||
13845 | ParcelAbandonRequest handlerParcelAbandonRequest = OnParcelAbandonRequest; | ||
13846 | if (handlerParcelAbandonRequest != null) | ||
13847 | { | ||
13848 | handlerParcelAbandonRequest(releasePacket.Data.LocalID, this); | ||
13849 | } | ||
13850 | break; | ||
13851 | |||
13852 | case PacketType.ParcelReclaim: | ||
13853 | ParcelReclaimPacket reclaimPacket = (ParcelReclaimPacket)Pack; | ||
13854 | |||
13855 | #region Packet Session and User Check | ||
13856 | if (m_checkPackets) | ||
13857 | { | ||
13858 | if (reclaimPacket.AgentData.SessionID != SessionId || | ||
13859 | reclaimPacket.AgentData.AgentID != AgentId) | ||
13860 | break; | ||
13861 | } | ||
13862 | #endregion | ||
13863 | |||
13864 | ParcelReclaim handlerParcelReclaim = OnParcelReclaim; | ||
13865 | if (handlerParcelReclaim != null) | ||
13866 | { | ||
13867 | handlerParcelReclaim(reclaimPacket.Data.LocalID, this); | ||
13868 | } | ||
13869 | break; | ||
13870 | |||
13871 | case PacketType.ParcelReturnObjects: | ||
13872 | |||
13873 | |||
13874 | ParcelReturnObjectsPacket parcelReturnObjects = (ParcelReturnObjectsPacket)Pack; | ||
13875 | |||
13876 | #region Packet Session and User Check | ||
13877 | if (m_checkPackets) | ||
13878 | { | ||
13879 | if (parcelReturnObjects.AgentData.SessionID != SessionId || | ||
13880 | parcelReturnObjects.AgentData.AgentID != AgentId) | ||
13881 | break; | ||
13882 | } | ||
13883 | #endregion | ||
13884 | |||
13885 | UUID[] puserselectedOwnerIDs = new UUID[parcelReturnObjects.OwnerIDs.Length]; | ||
13886 | for (int parceliterator = 0; parceliterator < parcelReturnObjects.OwnerIDs.Length; parceliterator++) | ||
13887 | puserselectedOwnerIDs[parceliterator] = parcelReturnObjects.OwnerIDs[parceliterator].OwnerID; | ||
13888 | |||
13889 | UUID[] puserselectedTaskIDs = new UUID[parcelReturnObjects.TaskIDs.Length]; | ||
13890 | |||
13891 | for (int parceliterator = 0; parceliterator < parcelReturnObjects.TaskIDs.Length; parceliterator++) | ||
13892 | puserselectedTaskIDs[parceliterator] = parcelReturnObjects.TaskIDs[parceliterator].TaskID; | ||
13893 | |||
13894 | ParcelReturnObjectsRequest handlerParcelReturnObjectsRequest = OnParcelReturnObjectsRequest; | ||
13895 | if (handlerParcelReturnObjectsRequest != null) | ||
13896 | { | ||
13897 | handlerParcelReturnObjectsRequest(parcelReturnObjects.ParcelData.LocalID, parcelReturnObjects.ParcelData.ReturnType, puserselectedOwnerIDs, puserselectedTaskIDs, this); | ||
13898 | |||
13899 | } | ||
13900 | break; | ||
13901 | |||
13902 | case PacketType.ParcelSetOtherCleanTime: | ||
13903 | ParcelSetOtherCleanTimePacket parcelSetOtherCleanTimePacket = (ParcelSetOtherCleanTimePacket)Pack; | ||
13904 | |||
13905 | #region Packet Session and User Check | ||
13906 | if (m_checkPackets) | ||
13907 | { | ||
13908 | if (parcelSetOtherCleanTimePacket.AgentData.SessionID != SessionId || | ||
13909 | parcelSetOtherCleanTimePacket.AgentData.AgentID != AgentId) | ||
13910 | break; | ||
13911 | } | ||
13912 | #endregion | ||
13913 | |||
13914 | ParcelSetOtherCleanTime handlerParcelSetOtherCleanTime = OnParcelSetOtherCleanTime; | ||
13915 | if (handlerParcelSetOtherCleanTime != null) | ||
13916 | { | ||
13917 | handlerParcelSetOtherCleanTime(this, | ||
13918 | parcelSetOtherCleanTimePacket.ParcelData.LocalID, | ||
13919 | parcelSetOtherCleanTimePacket.ParcelData.OtherCleanTime); | ||
13920 | } | ||
13921 | break; | ||
13922 | |||
13923 | case PacketType.LandStatRequest: | ||
13924 | LandStatRequestPacket lsrp = (LandStatRequestPacket)Pack; | ||
13925 | |||
13926 | #region Packet Session and User Check | ||
13927 | if (m_checkPackets) | ||
13928 | { | ||
13929 | if (lsrp.AgentData.SessionID != SessionId || | ||
13930 | lsrp.AgentData.AgentID != AgentId) | ||
13931 | break; | ||
13932 | } | ||
13933 | #endregion | ||
13934 | |||
13935 | GodLandStatRequest handlerLandStatRequest = OnLandStatRequest; | ||
13936 | if (handlerLandStatRequest != null) | ||
13937 | { | ||
13938 | handlerLandStatRequest(lsrp.RequestData.ParcelLocalID, lsrp.RequestData.ReportType, lsrp.RequestData.RequestFlags, Utils.BytesToString(lsrp.RequestData.Filter), this); | ||
13939 | } | ||
13940 | break; | ||
13941 | |||
13942 | case PacketType.ParcelDwellRequest: | ||
13943 | ParcelDwellRequestPacket dwellrq = | ||
13944 | (ParcelDwellRequestPacket)Pack; | ||
13945 | |||
13946 | #region Packet Session and User Check | ||
13947 | if (m_checkPackets) | ||
13948 | { | ||
13949 | if (dwellrq.AgentData.SessionID != SessionId || | ||
13950 | dwellrq.AgentData.AgentID != AgentId) | ||
13951 | break; | ||
13952 | } | ||
13953 | #endregion | ||
13954 | |||
13955 | ParcelDwellRequest handlerParcelDwellRequest = OnParcelDwellRequest; | ||
13956 | if (handlerParcelDwellRequest != null) | ||
13957 | { | ||
13958 | handlerParcelDwellRequest(dwellrq.Data.LocalID, this); | ||
13959 | } | ||
13960 | break; | ||
13961 | |||
13962 | //#endregion | ||
13963 | |||
13964 | //#region Estate Packets | ||
13965 | |||
13966 | case PacketType.EstateOwnerMessage: | ||
13967 | EstateOwnerMessagePacket messagePacket = (EstateOwnerMessagePacket)Pack; | ||
13968 | //m_log.Debug(messagePacket.ToString()); | ||
13969 | |||
13970 | #region Packet Session and User Check | ||
13971 | if (m_checkPackets) | ||
13972 | { | ||
13973 | if (messagePacket.AgentData.SessionID != SessionId || | ||
13974 | messagePacket.AgentData.AgentID != AgentId) | ||
13975 | break; | ||
13976 | } | ||
13977 | #endregion | ||
13978 | |||
13979 | switch (Utils.BytesToString(messagePacket.MethodData.Method)) | ||
13980 | { | ||
13981 | case "getinfo": | ||
13982 | if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false)) | ||
13983 | { | ||
13984 | OnDetailedEstateDataRequest(this, messagePacket.MethodData.Invoice); | ||
13985 | } | ||
13986 | break; | ||
13987 | case "setregioninfo": | ||
13988 | if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false)) | ||
13989 | { | ||
13990 | OnSetEstateFlagsRequest(convertParamStringToBool(messagePacket.ParamList[0].Parameter), convertParamStringToBool(messagePacket.ParamList[1].Parameter), | ||
13991 | convertParamStringToBool(messagePacket.ParamList[2].Parameter), !convertParamStringToBool(messagePacket.ParamList[3].Parameter), | ||
13992 | Convert.ToInt16(Convert.ToDecimal(Utils.BytesToString(messagePacket.ParamList[4].Parameter), Culture.NumberFormatInfo)), | ||
13993 | (float)Convert.ToDecimal(Utils.BytesToString(messagePacket.ParamList[5].Parameter), Culture.NumberFormatInfo), | ||
13994 | Convert.ToInt16(Utils.BytesToString(messagePacket.ParamList[6].Parameter)), | ||
13995 | convertParamStringToBool(messagePacket.ParamList[7].Parameter), convertParamStringToBool(messagePacket.ParamList[8].Parameter)); | ||
13996 | } | ||
13997 | break; | ||
13998 | // case "texturebase": | ||
13999 | // if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false)) | ||
14000 | // { | ||
14001 | // foreach (EstateOwnerMessagePacket.ParamListBlock block in messagePacket.ParamList) | ||
14002 | // { | ||
14003 | // string s = Utils.BytesToString(block.Parameter); | ||
14004 | // string[] splitField = s.Split(' '); | ||
14005 | // if (splitField.Length == 2) | ||
14006 | // { | ||
14007 | // UUID tempUUID = new UUID(splitField[1]); | ||
14008 | // OnSetEstateTerrainBaseTexture(this, Convert.ToInt16(splitField[0]), tempUUID); | ||
14009 | // } | ||
14010 | // } | ||
14011 | // } | ||
14012 | // break; | ||
14013 | case "texturedetail": | ||
14014 | if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false)) | ||
14015 | { | ||
14016 | foreach (EstateOwnerMessagePacket.ParamListBlock block in messagePacket.ParamList) | ||
14017 | { | ||
14018 | string s = Utils.BytesToString(block.Parameter); | ||
14019 | string[] splitField = s.Split(' '); | ||
14020 | if (splitField.Length == 2) | ||
14021 | { | ||
14022 | Int16 corner = Convert.ToInt16(splitField[0]); | ||
14023 | UUID textureUUID = new UUID(splitField[1]); | ||
14024 | |||
14025 | OnSetEstateTerrainDetailTexture(this, corner, textureUUID); | ||
14026 | } | ||
14027 | } | ||
14028 | } | ||
14029 | |||
14030 | break; | ||
14031 | case "textureheights": | ||
14032 | if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false)) | ||
14033 | { | ||
14034 | foreach (EstateOwnerMessagePacket.ParamListBlock block in messagePacket.ParamList) | ||
14035 | { | ||
14036 | string s = Utils.BytesToString(block.Parameter); | ||
14037 | string[] splitField = s.Split(' '); | ||
14038 | if (splitField.Length == 3) | ||
14039 | { | ||
14040 | Int16 corner = Convert.ToInt16(splitField[0]); | ||
14041 | float lowValue = (float)Convert.ToDecimal(splitField[1], Culture.NumberFormatInfo); | ||
14042 | float highValue = (float)Convert.ToDecimal(splitField[2], Culture.NumberFormatInfo); | ||
14043 | |||
14044 | OnSetEstateTerrainTextureHeights(this, corner, lowValue, highValue); | ||
14045 | } | ||
14046 | } | ||
14047 | } | ||
14048 | break; | ||
14049 | case "texturecommit": | ||
14050 | OnCommitEstateTerrainTextureRequest(this); | ||
14051 | break; | ||
14052 | case "setregionterrain": | ||
14053 | if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false)) | ||
14054 | { | ||
14055 | if (messagePacket.ParamList.Length != 9) | ||
14056 | { | ||
14057 | m_log.Error("EstateOwnerMessage: SetRegionTerrain method has a ParamList of invalid length"); | ||
14058 | } | ||
14059 | else | ||
14060 | { | ||
14061 | try | ||
14062 | { | ||
14063 | string tmp = Utils.BytesToString(messagePacket.ParamList[0].Parameter); | ||
14064 | if (!tmp.Contains(".")) tmp += ".00"; | ||
14065 | float WaterHeight = (float)Convert.ToDecimal(tmp, Culture.NumberFormatInfo); | ||
14066 | tmp = Utils.BytesToString(messagePacket.ParamList[1].Parameter); | ||
14067 | if (!tmp.Contains(".")) tmp += ".00"; | ||
14068 | float TerrainRaiseLimit = (float)Convert.ToDecimal(tmp, Culture.NumberFormatInfo); | ||
14069 | tmp = Utils.BytesToString(messagePacket.ParamList[2].Parameter); | ||
14070 | if (!tmp.Contains(".")) tmp += ".00"; | ||
14071 | float TerrainLowerLimit = (float)Convert.ToDecimal(tmp, Culture.NumberFormatInfo); | ||
14072 | bool UseEstateSun = convertParamStringToBool(messagePacket.ParamList[3].Parameter); | ||
14073 | bool UseFixedSun = convertParamStringToBool(messagePacket.ParamList[4].Parameter); | ||
14074 | float SunHour = (float)Convert.ToDecimal(Utils.BytesToString(messagePacket.ParamList[5].Parameter), Culture.NumberFormatInfo); | ||
14075 | bool UseGlobal = convertParamStringToBool(messagePacket.ParamList[6].Parameter); | ||
14076 | bool EstateFixedSun = convertParamStringToBool(messagePacket.ParamList[7].Parameter); | ||
14077 | float EstateSunHour = (float)Convert.ToDecimal(Utils.BytesToString(messagePacket.ParamList[8].Parameter), Culture.NumberFormatInfo); | ||
14078 | |||
14079 | OnSetRegionTerrainSettings(WaterHeight, TerrainRaiseLimit, TerrainLowerLimit, UseEstateSun, UseFixedSun, SunHour, UseGlobal, EstateFixedSun, EstateSunHour); | ||
14080 | |||
14081 | } | ||
14082 | catch (Exception ex) | ||
14083 | { | ||
14084 | m_log.Error("EstateOwnerMessage: Exception while setting terrain settings: \n" + messagePacket + "\n" + ex); | ||
14085 | } | ||
14086 | } | ||
14087 | } | ||
14088 | |||
14089 | break; | ||
14090 | case "restart": | ||
14091 | if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false)) | ||
14092 | { | ||
14093 | // There's only 1 block in the estateResetSim.. and that's the number of seconds till restart. | ||
14094 | foreach (EstateOwnerMessagePacket.ParamListBlock block in messagePacket.ParamList) | ||
14095 | { | ||
14096 | float timeSeconds; | ||
14097 | Utils.TryParseSingle(Utils.BytesToString(block.Parameter), out timeSeconds); | ||
14098 | timeSeconds = (int)timeSeconds; | ||
14099 | OnEstateRestartSimRequest(this, (int)timeSeconds); | ||
14100 | |||
14101 | } | ||
14102 | } | ||
14103 | break; | ||
14104 | case "estatechangecovenantid": | ||
14105 | if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false)) | ||
14106 | { | ||
14107 | foreach (EstateOwnerMessagePacket.ParamListBlock block in messagePacket.ParamList) | ||
14108 | { | ||
14109 | UUID newCovenantID = new UUID(Utils.BytesToString(block.Parameter)); | ||
14110 | OnEstateChangeCovenantRequest(this, newCovenantID); | ||
14111 | } | ||
14112 | } | ||
14113 | break; | ||
14114 | case "estateaccessdelta": // Estate access delta manages the banlist and allow list too. | ||
14115 | if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false)) | ||
14116 | { | ||
14117 | int estateAccessType = Convert.ToInt16(Utils.BytesToString(messagePacket.ParamList[1].Parameter)); | ||
14118 | OnUpdateEstateAccessDeltaRequest(this, messagePacket.MethodData.Invoice, estateAccessType, new UUID(Utils.BytesToString(messagePacket.ParamList[2].Parameter))); | ||
14119 | |||
14120 | } | ||
14121 | break; | ||
14122 | case "simulatormessage": | ||
14123 | if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false)) | ||
14124 | { | ||
14125 | UUID invoice = messagePacket.MethodData.Invoice; | ||
14126 | UUID SenderID = new UUID(Utils.BytesToString(messagePacket.ParamList[2].Parameter)); | ||
14127 | string SenderName = Utils.BytesToString(messagePacket.ParamList[3].Parameter); | ||
14128 | string Message = Utils.BytesToString(messagePacket.ParamList[4].Parameter); | ||
14129 | UUID sessionID = messagePacket.AgentData.SessionID; | ||
14130 | OnSimulatorBlueBoxMessageRequest(this, invoice, SenderID, sessionID, SenderName, Message); | ||
14131 | } | ||
14132 | break; | ||
14133 | case "instantmessage": | ||
14134 | if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false)) | ||
14135 | { | ||
14136 | if (messagePacket.ParamList.Length < 5) | ||
14137 | break; | ||
14138 | UUID invoice = messagePacket.MethodData.Invoice; | ||
14139 | UUID SenderID = new UUID(Utils.BytesToString(messagePacket.ParamList[2].Parameter)); | ||
14140 | string SenderName = Utils.BytesToString(messagePacket.ParamList[3].Parameter); | ||
14141 | string Message = Utils.BytesToString(messagePacket.ParamList[4].Parameter); | ||
14142 | UUID sessionID = messagePacket.AgentData.SessionID; | ||
14143 | OnEstateBlueBoxMessageRequest(this, invoice, SenderID, sessionID, SenderName, Message); | ||
14144 | } | ||
14145 | break; | ||
14146 | case "setregiondebug": | ||
14147 | if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false)) | ||
14148 | { | ||
14149 | UUID invoice = messagePacket.MethodData.Invoice; | ||
14150 | UUID SenderID = messagePacket.AgentData.AgentID; | ||
14151 | bool scripted = convertParamStringToBool(messagePacket.ParamList[0].Parameter); | ||
14152 | bool collisionEvents = convertParamStringToBool(messagePacket.ParamList[1].Parameter); | ||
14153 | bool physics = convertParamStringToBool(messagePacket.ParamList[2].Parameter); | ||
14154 | |||
14155 | OnEstateDebugRegionRequest(this, invoice, SenderID, scripted, collisionEvents, physics); | ||
14156 | } | ||
14157 | break; | ||
14158 | case "teleporthomeuser": | ||
14159 | if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false)) | ||
14160 | { | ||
14161 | UUID invoice = messagePacket.MethodData.Invoice; | ||
14162 | UUID SenderID = messagePacket.AgentData.AgentID; | ||
14163 | UUID Prey; | ||
14164 | |||
14165 | UUID.TryParse(Utils.BytesToString(messagePacket.ParamList[1].Parameter), out Prey); | ||
14166 | |||
14167 | OnEstateTeleportOneUserHomeRequest(this, invoice, SenderID, Prey); | ||
14168 | } | ||
14169 | break; | ||
14170 | case "teleporthomeallusers": | ||
14171 | if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false)) | ||
14172 | { | ||
14173 | UUID invoice = messagePacket.MethodData.Invoice; | ||
14174 | UUID SenderID = messagePacket.AgentData.AgentID; | ||
14175 | OnEstateTeleportAllUsersHomeRequest(this, invoice, SenderID); | ||
14176 | } | ||
14177 | break; | ||
14178 | case "colliders": | ||
14179 | handlerLandStatRequest = OnLandStatRequest; | ||
14180 | if (handlerLandStatRequest != null) | ||
14181 | { | ||
14182 | handlerLandStatRequest(0, 1, 0, "", this); | ||
14183 | } | ||
14184 | break; | ||
14185 | case "scripts": | ||
14186 | handlerLandStatRequest = OnLandStatRequest; | ||
14187 | if (handlerLandStatRequest != null) | ||
14188 | { | ||
14189 | handlerLandStatRequest(0, 0, 0, "", this); | ||
14190 | } | ||
14191 | break; | ||
14192 | case "terrain": | ||
14193 | if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false)) | ||
14194 | { | ||
14195 | if (messagePacket.ParamList.Length > 0) | ||
14196 | { | ||
14197 | if (Utils.BytesToString(messagePacket.ParamList[0].Parameter) == "bake") | ||
14198 | { | ||
14199 | BakeTerrain handlerBakeTerrain = OnBakeTerrain; | ||
14200 | if (handlerBakeTerrain != null) | ||
14201 | { | ||
14202 | handlerBakeTerrain(this); | ||
14203 | } | ||
14204 | } | ||
14205 | if (Utils.BytesToString(messagePacket.ParamList[0].Parameter) == "download filename") | ||
14206 | { | ||
14207 | if (messagePacket.ParamList.Length > 1) | ||
14208 | { | ||
14209 | RequestTerrain handlerRequestTerrain = OnRequestTerrain; | ||
14210 | if (handlerRequestTerrain != null) | ||
14211 | { | ||
14212 | handlerRequestTerrain(this, Utils.BytesToString(messagePacket.ParamList[1].Parameter)); | ||
14213 | } | ||
14214 | } | ||
14215 | } | ||
14216 | if (Utils.BytesToString(messagePacket.ParamList[0].Parameter) == "upload filename") | ||
14217 | { | ||
14218 | if (messagePacket.ParamList.Length > 1) | ||
14219 | { | ||
14220 | RequestTerrain handlerUploadTerrain = OnUploadTerrain; | ||
14221 | if (handlerUploadTerrain != null) | ||
14222 | { | ||
14223 | handlerUploadTerrain(this, Utils.BytesToString(messagePacket.ParamList[1].Parameter)); | ||
14224 | } | ||
14225 | } | ||
14226 | } | ||
14227 | |||
14228 | } | ||
14229 | |||
14230 | |||
14231 | } | ||
14232 | break; | ||
14233 | |||
14234 | case "estatechangeinfo": | ||
14235 | if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false)) | ||
14236 | { | ||
14237 | UUID invoice = messagePacket.MethodData.Invoice; | ||
14238 | UUID SenderID = messagePacket.AgentData.AgentID; | ||
14239 | UInt32 param1 = Convert.ToUInt32(Utils.BytesToString(messagePacket.ParamList[1].Parameter)); | ||
14240 | UInt32 param2 = Convert.ToUInt32(Utils.BytesToString(messagePacket.ParamList[2].Parameter)); | ||
14241 | |||
14242 | EstateChangeInfo handlerEstateChangeInfo = OnEstateChangeInfo; | ||
14243 | if (handlerEstateChangeInfo != null) | ||
14244 | { | ||
14245 | handlerEstateChangeInfo(this, invoice, SenderID, param1, param2); | ||
14246 | } | ||
14247 | } | ||
14248 | break; | ||
14249 | |||
14250 | default: | ||
14251 | m_log.Error("EstateOwnerMessage: Unknown method requested\n" + messagePacket); | ||
14252 | break; | ||
14253 | } | ||
14254 | |||
14255 | //int parcelID, uint reportType, uint requestflags, string filter | ||
14256 | |||
14257 | //lsrp.RequestData.ParcelLocalID; | ||
14258 | //lsrp.RequestData.ReportType; // 1 = colliders, 0 = scripts | ||
14259 | //lsrp.RequestData.RequestFlags; | ||
14260 | //lsrp.RequestData.Filter; | ||
14261 | |||
14262 | break; | ||
14263 | |||
14264 | case PacketType.RequestRegionInfo: | ||
14265 | RequestRegionInfoPacket.AgentDataBlock mPacket = ((RequestRegionInfoPacket)Pack).AgentData; | ||
14266 | |||
14267 | #region Packet Session and User Check | ||
14268 | if (m_checkPackets) | ||
14269 | { | ||
14270 | if (mPacket.SessionID != SessionId || | ||
14271 | mPacket.AgentID != AgentId) | ||
14272 | break; | ||
14273 | } | ||
14274 | #endregion | ||
14275 | |||
14276 | RegionInfoRequest handlerRegionInfoRequest = OnRegionInfoRequest; | ||
14277 | if (handlerRegionInfoRequest != null) | ||
14278 | { | ||
14279 | handlerRegionInfoRequest(this); | ||
14280 | } | ||
14281 | break; | ||
14282 | |||
14283 | case PacketType.EstateCovenantRequest: | ||
14284 | |||
14285 | //EstateCovenantRequestPacket.AgentDataBlock epack = | ||
14286 | // ((EstateCovenantRequestPacket)Pack).AgentData; | ||
14287 | |||
14288 | EstateCovenantRequest handlerEstateCovenantRequest = OnEstateCovenantRequest; | ||
14289 | if (handlerEstateCovenantRequest != null) | ||
14290 | { | ||
14291 | handlerEstateCovenantRequest(this); | ||
14292 | } | ||
14293 | break; | ||
14294 | |||
14295 | //#endregion | ||
14296 | |||
14297 | //#region GodPackets | ||
14298 | |||
14299 | case PacketType.RequestGodlikePowers: | ||
14300 | RequestGodlikePowersPacket rglpPack = (RequestGodlikePowersPacket)Pack; | ||
14301 | RequestGodlikePowersPacket.RequestBlockBlock rblock = rglpPack.RequestBlock; | ||
14302 | UUID token = rblock.Token; | ||
14303 | |||
14304 | RequestGodlikePowersPacket.AgentDataBlock ablock = rglpPack.AgentData; | ||
14305 | |||
14306 | RequestGodlikePowers handlerReqGodlikePowers = OnRequestGodlikePowers; | ||
14307 | |||
14308 | if (handlerReqGodlikePowers != null) | ||
14309 | { | ||
14310 | handlerReqGodlikePowers(ablock.AgentID, ablock.SessionID, token, rblock.Godlike, this); | ||
14311 | } | ||
14312 | |||
14313 | break; | ||
14314 | |||
14315 | case PacketType.GodKickUser: | ||
14316 | GodKickUserPacket gkupack = (GodKickUserPacket)Pack; | ||
14317 | |||
14318 | if (gkupack.UserInfo.GodSessionID == SessionId && AgentId == gkupack.UserInfo.GodID) | ||
14319 | { | ||
14320 | GodKickUser handlerGodKickUser = OnGodKickUser; | ||
14321 | if (handlerGodKickUser != null) | ||
14322 | { | ||
14323 | handlerGodKickUser(gkupack.UserInfo.GodID, gkupack.UserInfo.GodSessionID, | ||
14324 | gkupack.UserInfo.AgentID, gkupack.UserInfo.KickFlags, gkupack.UserInfo.Reason,gkupack.UserInfo); | ||
14325 | } | ||
14326 | } | ||
14327 | else | ||
14328 | { | ||
14329 | SendAgentAlertMessage("Kick request denied", false); | ||
14330 | } | ||
14331 | //KickUserPacket kupack = new KickUserPacket(); | ||
14332 | //KickUserPacket.UserInfoBlock kupackib = kupack.UserInfo; | ||
14333 | |||
14334 | //kupack.UserInfo.AgentID = gkupack.UserInfo.AgentID; | ||
14335 | //kupack.UserInfo.SessionID = gkupack.UserInfo.GodSessionID; | ||
14336 | |||
14337 | //kupack.TargetBlock.TargetIP = (uint)0; | ||
14338 | //kupack.TargetBlock.TargetPort = (ushort)0; | ||
14339 | //kupack.UserInfo.Reason = gkupack.UserInfo.Reason; | ||
14340 | |||
14341 | //OutPacket(kupack, ThrottleOutPacketType.Task); | ||
14342 | break; | ||
14343 | |||
14344 | //#endregion | ||
14345 | |||
14346 | //#region Economy/Transaction Packets | ||
14347 | |||
14348 | case PacketType.MoneyBalanceRequest: | ||
14349 | MoneyBalanceRequestPacket moneybalancerequestpacket = (MoneyBalanceRequestPacket)Pack; | ||
14350 | |||
14351 | #region Packet Session and User Check | ||
14352 | if (m_checkPackets) | ||
14353 | { | ||
14354 | if (moneybalancerequestpacket.AgentData.SessionID != SessionId || | ||
14355 | moneybalancerequestpacket.AgentData.AgentID != AgentId) | ||
14356 | break; | ||
14357 | } | ||
14358 | #endregion | ||
14359 | |||
14360 | MoneyBalanceRequest handlerMoneyBalanceRequest = OnMoneyBalanceRequest; | ||
14361 | |||
14362 | if (handlerMoneyBalanceRequest != null) | ||
14363 | { | ||
14364 | handlerMoneyBalanceRequest(this, moneybalancerequestpacket.AgentData.AgentID, moneybalancerequestpacket.AgentData.SessionID, moneybalancerequestpacket.MoneyData.TransactionID); | ||
14365 | } | ||
14366 | |||
14367 | break; | ||
14368 | |||
14369 | case PacketType.EconomyDataRequest: | ||
14370 | |||
14371 | |||
14372 | EconomyDataRequest handlerEconomoyDataRequest = OnEconomyDataRequest; | ||
14373 | if (handlerEconomoyDataRequest != null) | ||
14374 | { | ||
14375 | handlerEconomoyDataRequest(AgentId); | ||
14376 | } | ||
14377 | break; | ||
14378 | |||
14379 | case PacketType.RequestPayPrice: | ||
14380 | RequestPayPricePacket requestPayPricePacket = (RequestPayPricePacket)Pack; | ||
14381 | |||
14382 | RequestPayPrice handlerRequestPayPrice = OnRequestPayPrice; | ||
14383 | if (handlerRequestPayPrice != null) | ||
14384 | { | ||
14385 | handlerRequestPayPrice(this, requestPayPricePacket.ObjectData.ObjectID); | ||
14386 | } | ||
14387 | break; | ||
14388 | |||
14389 | case PacketType.ObjectSaleInfo: | ||
14390 | ObjectSaleInfoPacket objectSaleInfoPacket = (ObjectSaleInfoPacket)Pack; | ||
14391 | |||
14392 | #region Packet Session and User Check | ||
14393 | if (m_checkPackets) | ||
14394 | { | ||
14395 | if (objectSaleInfoPacket.AgentData.SessionID != SessionId || | ||
14396 | objectSaleInfoPacket.AgentData.AgentID != AgentId) | ||
14397 | break; | ||
14398 | } | ||
14399 | #endregion | ||
14400 | |||
14401 | ObjectSaleInfo handlerObjectSaleInfo = OnObjectSaleInfo; | ||
14402 | if (handlerObjectSaleInfo != null) | ||
14403 | { | ||
14404 | foreach (ObjectSaleInfoPacket.ObjectDataBlock d | ||
14405 | in objectSaleInfoPacket.ObjectData) | ||
14406 | { | ||
14407 | handlerObjectSaleInfo(this, | ||
14408 | objectSaleInfoPacket.AgentData.AgentID, | ||
14409 | objectSaleInfoPacket.AgentData.SessionID, | ||
14410 | d.LocalID, | ||
14411 | d.SaleType, | ||
14412 | d.SalePrice); | ||
14413 | } | ||
14414 | } | ||
14415 | break; | ||
14416 | |||
14417 | case PacketType.ObjectBuy: | ||
14418 | ObjectBuyPacket objectBuyPacket = (ObjectBuyPacket)Pack; | ||
14419 | |||
14420 | #region Packet Session and User Check | ||
14421 | if (m_checkPackets) | ||
14422 | { | ||
14423 | if (objectBuyPacket.AgentData.SessionID != SessionId || | ||
14424 | objectBuyPacket.AgentData.AgentID != AgentId) | ||
14425 | break; | ||
14426 | } | ||
14427 | #endregion | ||
14428 | |||
14429 | ObjectBuy handlerObjectBuy = OnObjectBuy; | ||
14430 | |||
14431 | if (handlerObjectBuy != null) | ||
14432 | { | ||
14433 | foreach (ObjectBuyPacket.ObjectDataBlock d | ||
14434 | in objectBuyPacket.ObjectData) | ||
14435 | { | ||
14436 | handlerObjectBuy(this, | ||
14437 | objectBuyPacket.AgentData.AgentID, | ||
14438 | objectBuyPacket.AgentData.SessionID, | ||
14439 | objectBuyPacket.AgentData.GroupID, | ||
14440 | objectBuyPacket.AgentData.CategoryID, | ||
14441 | d.ObjectLocalID, | ||
14442 | d.SaleType, | ||
14443 | d.SalePrice); | ||
14444 | } | ||
14445 | } | ||
14446 | break; | ||
14447 | |||
14448 | //#endregion | ||
14449 | |||
14450 | //#region Script Packets | ||
14451 | |||
14452 | case PacketType.GetScriptRunning: | ||
14453 | GetScriptRunningPacket scriptRunning = (GetScriptRunningPacket)Pack; | ||
14454 | |||
14455 | GetScriptRunning handlerGetScriptRunning = OnGetScriptRunning; | ||
14456 | if (handlerGetScriptRunning != null) | ||
14457 | { | ||
14458 | handlerGetScriptRunning(this, scriptRunning.Script.ObjectID, scriptRunning.Script.ItemID); | ||
14459 | } | ||
14460 | break; | ||
14461 | |||
14462 | case PacketType.SetScriptRunning: | ||
14463 | SetScriptRunningPacket setScriptRunning = (SetScriptRunningPacket)Pack; | ||
14464 | |||
14465 | #region Packet Session and User Check | ||
14466 | if (m_checkPackets) | ||
14467 | { | ||
14468 | if (setScriptRunning.AgentData.SessionID != SessionId || | ||
14469 | setScriptRunning.AgentData.AgentID != AgentId) | ||
14470 | break; | ||
14471 | } | ||
14472 | #endregion | ||
14473 | |||
14474 | SetScriptRunning handlerSetScriptRunning = OnSetScriptRunning; | ||
14475 | if (handlerSetScriptRunning != null) | ||
14476 | { | ||
14477 | handlerSetScriptRunning(this, setScriptRunning.Script.ObjectID, setScriptRunning.Script.ItemID, setScriptRunning.Script.Running); | ||
14478 | } | ||
14479 | break; | ||
14480 | |||
14481 | case PacketType.ScriptReset: | ||
14482 | ScriptResetPacket scriptResetPacket = (ScriptResetPacket)Pack; | ||
14483 | |||
14484 | #region Packet Session and User Check | ||
14485 | if (m_checkPackets) | ||
14486 | { | ||
14487 | if (scriptResetPacket.AgentData.SessionID != SessionId || | ||
14488 | scriptResetPacket.AgentData.AgentID != AgentId) | ||
14489 | break; | ||
14490 | } | ||
14491 | #endregion | ||
14492 | |||
14493 | ScriptReset handlerScriptReset = OnScriptReset; | ||
14494 | if (handlerScriptReset != null) | ||
14495 | { | ||
14496 | handlerScriptReset(this, scriptResetPacket.Script.ObjectID, scriptResetPacket.Script.ItemID); | ||
14497 | } | ||
14498 | break; | ||
14499 | |||
14500 | //#endregion | ||
14501 | |||
14502 | //#region Gesture Managment | ||
14503 | |||
14504 | case PacketType.ActivateGestures: | ||
14505 | ActivateGesturesPacket activateGesturePacket = (ActivateGesturesPacket)Pack; | ||
14506 | |||
14507 | #region Packet Session and User Check | ||
14508 | if (m_checkPackets) | ||
14509 | { | ||
14510 | if (activateGesturePacket.AgentData.SessionID != SessionId || | ||
14511 | activateGesturePacket.AgentData.AgentID != AgentId) | ||
14512 | break; | ||
14513 | } | ||
14514 | #endregion | ||
14515 | |||
14516 | ActivateGesture handlerActivateGesture = OnActivateGesture; | ||
14517 | if (handlerActivateGesture != null) | ||
14518 | { | ||
14519 | handlerActivateGesture(this, | ||
14520 | activateGesturePacket.Data[0].AssetID, | ||
14521 | activateGesturePacket.Data[0].ItemID); | ||
14522 | } | ||
14523 | else m_log.Error("Null pointer for activateGesture"); | ||
14524 | |||
14525 | break; | ||
14526 | |||
14527 | case PacketType.DeactivateGestures: | ||
14528 | DeactivateGesturesPacket deactivateGesturePacket = (DeactivateGesturesPacket)Pack; | ||
14529 | |||
14530 | #region Packet Session and User Check | ||
14531 | if (m_checkPackets) | ||
14532 | { | ||
14533 | if (deactivateGesturePacket.AgentData.SessionID != SessionId || | ||
14534 | deactivateGesturePacket.AgentData.AgentID != AgentId) | ||
14535 | break; | ||
14536 | } | ||
14537 | #endregion | ||
14538 | |||
14539 | DeactivateGesture handlerDeactivateGesture = OnDeactivateGesture; | ||
14540 | if (handlerDeactivateGesture != null) | ||
14541 | { | ||
14542 | handlerDeactivateGesture(this, deactivateGesturePacket.Data[0].ItemID); | ||
14543 | } | ||
14544 | break; | ||
14545 | case PacketType.ObjectOwner: | ||
14546 | ObjectOwnerPacket objectOwnerPacket = (ObjectOwnerPacket)Pack; | ||
14547 | |||
14548 | #region Packet Session and User Check | ||
14549 | if (m_checkPackets) | ||
14550 | { | ||
14551 | if (objectOwnerPacket.AgentData.SessionID != SessionId || | ||
14552 | objectOwnerPacket.AgentData.AgentID != AgentId) | ||
14553 | break; | ||
14554 | } | ||
14555 | #endregion | ||
14556 | |||
14557 | List<uint> localIDs = new List<uint>(); | ||
14558 | |||
14559 | foreach (ObjectOwnerPacket.ObjectDataBlock d in objectOwnerPacket.ObjectData) | ||
14560 | localIDs.Add(d.ObjectLocalID); | ||
14561 | |||
14562 | ObjectOwner handlerObjectOwner = OnObjectOwner; | ||
14563 | if (handlerObjectOwner != null) | ||
14564 | { | ||
14565 | handlerObjectOwner(this, objectOwnerPacket.HeaderData.OwnerID, objectOwnerPacket.HeaderData.GroupID, localIDs); | ||
14566 | } | ||
14567 | break; | ||
14568 | |||
14569 | //#endregion | ||
14570 | |||
14571 | case PacketType.AgentFOV: | ||
14572 | AgentFOVPacket fovPacket = (AgentFOVPacket)Pack; | ||
14573 | |||
14574 | if (fovPacket.FOVBlock.GenCounter > m_agentFOVCounter) | ||
14575 | { | ||
14576 | m_agentFOVCounter = fovPacket.FOVBlock.GenCounter; | ||
14577 | AgentFOV handlerAgentFOV = OnAgentFOV; | ||
14578 | if (handlerAgentFOV != null) | ||
14579 | { | ||
14580 | handlerAgentFOV(this, fovPacket.FOVBlock.VerticalAngle); | ||
14581 | } | ||
14582 | } | ||
14583 | break; | ||
14584 | |||
14585 | //#region unimplemented handlers | ||
14586 | |||
14587 | case PacketType.ViewerStats: | ||
14588 | // TODO: handle this packet | ||
14589 | //m_log.Warn("[CLIENT]: unhandled ViewerStats packet"); | ||
14590 | break; | ||
14591 | |||
14592 | case PacketType.MapItemRequest: | ||
14593 | MapItemRequestPacket mirpk = (MapItemRequestPacket)Pack; | ||
14594 | |||
14595 | #region Packet Session and User Check | ||
14596 | if (m_checkPackets) | ||
14597 | { | ||
14598 | if (mirpk.AgentData.SessionID != SessionId || | ||
14599 | mirpk.AgentData.AgentID != AgentId) | ||
14600 | break; | ||
14601 | } | ||
14602 | #endregion | ||
14603 | |||
14604 | //m_log.Debug(mirpk.ToString()); | ||
14605 | MapItemRequest handlerMapItemRequest = OnMapItemRequest; | ||
14606 | if (handlerMapItemRequest != null) | ||
14607 | { | ||
14608 | handlerMapItemRequest(this, mirpk.AgentData.Flags, mirpk.AgentData.EstateID, | ||
14609 | mirpk.AgentData.Godlike, mirpk.RequestData.ItemType, | ||
14610 | mirpk.RequestData.RegionHandle); | ||
14611 | |||
14612 | } | ||
14613 | break; | ||
14614 | |||
14615 | case PacketType.TransferAbort: | ||
14616 | // TODO: handle this packet | ||
14617 | //m_log.Warn("[CLIENT]: unhandled TransferAbort packet"); | ||
14618 | break; | ||
14619 | |||
14620 | case PacketType.MuteListRequest: | ||
14621 | MuteListRequestPacket muteListRequest = | ||
14622 | (MuteListRequestPacket)Pack; | ||
14623 | |||
14624 | #region Packet Session and User Check | ||
14625 | if (m_checkPackets) | ||
14626 | { | ||
14627 | if (muteListRequest.AgentData.SessionID != SessionId || | ||
14628 | muteListRequest.AgentData.AgentID != AgentId) | ||
14629 | break; | ||
14630 | } | ||
14631 | #endregion | ||
14632 | |||
14633 | MuteListRequest handlerMuteListRequest = OnMuteListRequest; | ||
14634 | if (handlerMuteListRequest != null) | ||
14635 | { | ||
14636 | handlerMuteListRequest(this, muteListRequest.MuteData.MuteCRC); | ||
14637 | } | ||
14638 | else | ||
14639 | { | ||
14640 | SendUseCachedMuteList(); | ||
14641 | } | ||
14642 | break; | ||
14643 | |||
14644 | case PacketType.UseCircuitCode: | ||
14645 | // Don't display this one, we handle it at a lower level | ||
14646 | break; | ||
14647 | |||
14648 | case PacketType.AgentHeightWidth: | ||
14649 | // TODO: handle this packet | ||
14650 | //m_log.Warn("[CLIENT]: unhandled AgentHeightWidth packet"); | ||
14651 | break; | ||
14652 | |||
14653 | case PacketType.InventoryDescendents: | ||
14654 | // TODO: handle this packet | ||
14655 | //m_log.Warn("[CLIENT]: unhandled InventoryDescent packet"); | ||
14656 | |||
14657 | break; | ||
14658 | |||
14659 | case PacketType.DirPlacesQuery: | ||
14660 | DirPlacesQueryPacket dirPlacesQueryPacket = (DirPlacesQueryPacket)Pack; | ||
14661 | //m_log.Debug(dirPlacesQueryPacket.ToString()); | ||
14662 | |||
14663 | #region Packet Session and User Check | ||
14664 | if (m_checkPackets) | ||
14665 | { | ||
14666 | if (dirPlacesQueryPacket.AgentData.SessionID != SessionId || | ||
14667 | dirPlacesQueryPacket.AgentData.AgentID != AgentId) | ||
14668 | break; | ||
14669 | } | ||
14670 | #endregion | ||
14671 | |||
14672 | DirPlacesQuery handlerDirPlacesQuery = OnDirPlacesQuery; | ||
14673 | if (handlerDirPlacesQuery != null) | ||
14674 | { | ||
14675 | handlerDirPlacesQuery(this, | ||
14676 | dirPlacesQueryPacket.QueryData.QueryID, | ||
14677 | Utils.BytesToString( | ||
14678 | dirPlacesQueryPacket.QueryData.QueryText), | ||
14679 | (int)dirPlacesQueryPacket.QueryData.QueryFlags, | ||
14680 | (int)dirPlacesQueryPacket.QueryData.Category, | ||
14681 | Utils.BytesToString( | ||
14682 | dirPlacesQueryPacket.QueryData.SimName), | ||
14683 | dirPlacesQueryPacket.QueryData.QueryStart); | ||
14684 | } | ||
14685 | break; | ||
14686 | |||
14687 | case PacketType.DirFindQuery: | ||
14688 | DirFindQueryPacket dirFindQueryPacket = (DirFindQueryPacket)Pack; | ||
14689 | |||
14690 | #region Packet Session and User Check | ||
14691 | if (m_checkPackets) | ||
14692 | { | ||
14693 | if (dirFindQueryPacket.AgentData.SessionID != SessionId || | ||
14694 | dirFindQueryPacket.AgentData.AgentID != AgentId) | ||
14695 | break; | ||
14696 | } | ||
14697 | #endregion | ||
14698 | |||
14699 | DirFindQuery handlerDirFindQuery = OnDirFindQuery; | ||
14700 | if (handlerDirFindQuery != null) | ||
14701 | { | ||
14702 | handlerDirFindQuery(this, | ||
14703 | dirFindQueryPacket.QueryData.QueryID, | ||
14704 | Utils.BytesToString( | ||
14705 | dirFindQueryPacket.QueryData.QueryText), | ||
14706 | dirFindQueryPacket.QueryData.QueryFlags, | ||
14707 | dirFindQueryPacket.QueryData.QueryStart); | ||
14708 | } | ||
14709 | break; | ||
14710 | |||
14711 | case PacketType.DirLandQuery: | ||
14712 | DirLandQueryPacket dirLandQueryPacket = (DirLandQueryPacket)Pack; | ||
14713 | |||
14714 | #region Packet Session and User Check | ||
14715 | if (m_checkPackets) | ||
14716 | { | ||
14717 | if (dirLandQueryPacket.AgentData.SessionID != SessionId || | ||
14718 | dirLandQueryPacket.AgentData.AgentID != AgentId) | ||
14719 | break; | ||
14720 | } | ||
14721 | #endregion | ||
14722 | |||
14723 | DirLandQuery handlerDirLandQuery = OnDirLandQuery; | ||
14724 | if (handlerDirLandQuery != null) | ||
14725 | { | ||
14726 | handlerDirLandQuery(this, | ||
14727 | dirLandQueryPacket.QueryData.QueryID, | ||
14728 | dirLandQueryPacket.QueryData.QueryFlags, | ||
14729 | dirLandQueryPacket.QueryData.SearchType, | ||
14730 | dirLandQueryPacket.QueryData.Price, | ||
14731 | dirLandQueryPacket.QueryData.Area, | ||
14732 | dirLandQueryPacket.QueryData.QueryStart); | ||
14733 | } | ||
14734 | break; | ||
14735 | |||
14736 | case PacketType.DirPopularQuery: | ||
14737 | DirPopularQueryPacket dirPopularQueryPacket = (DirPopularQueryPacket)Pack; | ||
14738 | |||
14739 | #region Packet Session and User Check | ||
14740 | if (m_checkPackets) | ||
14741 | { | ||
14742 | if (dirPopularQueryPacket.AgentData.SessionID != SessionId || | ||
14743 | dirPopularQueryPacket.AgentData.AgentID != AgentId) | ||
14744 | break; | ||
14745 | } | ||
14746 | #endregion | ||
14747 | |||
14748 | DirPopularQuery handlerDirPopularQuery = OnDirPopularQuery; | ||
14749 | if (handlerDirPopularQuery != null) | ||
14750 | { | ||
14751 | handlerDirPopularQuery(this, | ||
14752 | dirPopularQueryPacket.QueryData.QueryID, | ||
14753 | dirPopularQueryPacket.QueryData.QueryFlags); | ||
14754 | } | ||
14755 | break; | ||
14756 | |||
14757 | case PacketType.DirClassifiedQuery: | ||
14758 | DirClassifiedQueryPacket dirClassifiedQueryPacket = (DirClassifiedQueryPacket)Pack; | ||
14759 | |||
14760 | #region Packet Session and User Check | ||
14761 | if (m_checkPackets) | ||
14762 | { | ||
14763 | if (dirClassifiedQueryPacket.AgentData.SessionID != SessionId || | ||
14764 | dirClassifiedQueryPacket.AgentData.AgentID != AgentId) | ||
14765 | break; | ||
14766 | } | ||
14767 | #endregion | ||
14768 | |||
14769 | DirClassifiedQuery handlerDirClassifiedQuery = OnDirClassifiedQuery; | ||
14770 | if (handlerDirClassifiedQuery != null) | ||
14771 | { | ||
14772 | handlerDirClassifiedQuery(this, | ||
14773 | dirClassifiedQueryPacket.QueryData.QueryID, | ||
14774 | Utils.BytesToString( | ||
14775 | dirClassifiedQueryPacket.QueryData.QueryText), | ||
14776 | dirClassifiedQueryPacket.QueryData.QueryFlags, | ||
14777 | dirClassifiedQueryPacket.QueryData.Category, | ||
14778 | dirClassifiedQueryPacket.QueryData.QueryStart); | ||
14779 | } | ||
14780 | break; | ||
14781 | |||
14782 | case PacketType.EventInfoRequest: | ||
14783 | EventInfoRequestPacket eventInfoRequestPacket = (EventInfoRequestPacket)Pack; | ||
14784 | |||
14785 | #region Packet Session and User Check | ||
14786 | if (m_checkPackets) | ||
14787 | { | ||
14788 | if (eventInfoRequestPacket.AgentData.SessionID != SessionId || | ||
14789 | eventInfoRequestPacket.AgentData.AgentID != AgentId) | ||
14790 | break; | ||
14791 | } | ||
14792 | #endregion | ||
14793 | |||
14794 | if (OnEventInfoRequest != null) | ||
14795 | { | ||
14796 | OnEventInfoRequest(this, eventInfoRequestPacket.EventData.EventID); | ||
14797 | } | ||
14798 | break; | ||
14799 | |||
14800 | //#region Calling Card | ||
14801 | |||
14802 | case PacketType.OfferCallingCard: | ||
14803 | OfferCallingCardPacket offerCallingCardPacket = (OfferCallingCardPacket)Pack; | ||
14804 | |||
14805 | #region Packet Session and User Check | ||
14806 | if (m_checkPackets) | ||
14807 | { | ||
14808 | if (offerCallingCardPacket.AgentData.SessionID != SessionId || | ||
14809 | offerCallingCardPacket.AgentData.AgentID != AgentId) | ||
14810 | break; | ||
14811 | } | ||
14812 | #endregion | ||
14813 | |||
14814 | if (OnOfferCallingCard != null) | ||
14815 | { | ||
14816 | OnOfferCallingCard(this, | ||
14817 | offerCallingCardPacket.AgentBlock.DestID, | ||
14818 | offerCallingCardPacket.AgentBlock.TransactionID); | ||
14819 | } | ||
14820 | break; | ||
14821 | |||
14822 | case PacketType.AcceptCallingCard: | ||
14823 | AcceptCallingCardPacket acceptCallingCardPacket = (AcceptCallingCardPacket)Pack; | ||
14824 | |||
14825 | #region Packet Session and User Check | ||
14826 | if (m_checkPackets) | ||
14827 | { | ||
14828 | if (acceptCallingCardPacket.AgentData.SessionID != SessionId || | ||
14829 | acceptCallingCardPacket.AgentData.AgentID != AgentId) | ||
14830 | break; | ||
14831 | } | ||
14832 | #endregion | ||
14833 | |||
14834 | // according to http://wiki.secondlife.com/wiki/AcceptCallingCard FolderData should | ||
14835 | // contain exactly one entry | ||
14836 | if (OnAcceptCallingCard != null && acceptCallingCardPacket.FolderData.Length > 0) | ||
14837 | { | ||
14838 | OnAcceptCallingCard(this, | ||
14839 | acceptCallingCardPacket.TransactionBlock.TransactionID, | ||
14840 | acceptCallingCardPacket.FolderData[0].FolderID); | ||
14841 | } | ||
14842 | break; | ||
14843 | |||
14844 | case PacketType.DeclineCallingCard: | ||
14845 | DeclineCallingCardPacket declineCallingCardPacket = (DeclineCallingCardPacket)Pack; | ||
14846 | |||
14847 | #region Packet Session and User Check | ||
14848 | if (m_checkPackets) | ||
14849 | { | ||
14850 | if (declineCallingCardPacket.AgentData.SessionID != SessionId || | ||
14851 | declineCallingCardPacket.AgentData.AgentID != AgentId) | ||
14852 | break; | ||
14853 | } | ||
14854 | #endregion | ||
14855 | |||
14856 | if (OnDeclineCallingCard != null) | ||
14857 | { | ||
14858 | OnDeclineCallingCard(this, | ||
14859 | declineCallingCardPacket.TransactionBlock.TransactionID); | ||
14860 | } | ||
14861 | break; | ||
14862 | //#endregion | ||
14863 | |||
14864 | //#region Groups | ||
14865 | case PacketType.ActivateGroup: | ||
14866 | ActivateGroupPacket activateGroupPacket = (ActivateGroupPacket)Pack; | ||
14867 | |||
14868 | #region Packet Session and User Check | ||
14869 | if (m_checkPackets) | ||
14870 | { | ||
14871 | if (activateGroupPacket.AgentData.SessionID != SessionId || | ||
14872 | activateGroupPacket.AgentData.AgentID != AgentId) | ||
14873 | break; | ||
14874 | } | ||
14875 | #endregion | ||
14876 | |||
14877 | if (m_GroupsModule != null) | ||
14878 | { | ||
14879 | m_GroupsModule.ActivateGroup(this, activateGroupPacket.AgentData.GroupID); | ||
14880 | m_GroupsModule.SendAgentGroupDataUpdate(this); | ||
14881 | } | ||
14882 | break; | ||
14883 | |||
14884 | |||
14885 | case PacketType.GroupTitlesRequest: | ||
14886 | GroupTitlesRequestPacket groupTitlesRequest = | ||
14887 | (GroupTitlesRequestPacket)Pack; | ||
14888 | |||
14889 | #region Packet Session and User Check | ||
14890 | if (m_checkPackets) | ||
14891 | { | ||
14892 | if (groupTitlesRequest.AgentData.SessionID != SessionId || | ||
14893 | groupTitlesRequest.AgentData.AgentID != AgentId) | ||
14894 | break; | ||
14895 | } | ||
14896 | #endregion | ||
14897 | |||
14898 | if (m_GroupsModule != null) | ||
14899 | { | ||
14900 | GroupTitlesReplyPacket groupTitlesReply = (GroupTitlesReplyPacket)PacketPool.Instance.GetPacket(PacketType.GroupTitlesReply); | ||
14901 | |||
14902 | groupTitlesReply.AgentData = | ||
14903 | new GroupTitlesReplyPacket.AgentDataBlock(); | ||
14904 | |||
14905 | groupTitlesReply.AgentData.AgentID = AgentId; | ||
14906 | groupTitlesReply.AgentData.GroupID = | ||
14907 | groupTitlesRequest.AgentData.GroupID; | ||
14908 | |||
14909 | groupTitlesReply.AgentData.RequestID = | ||
14910 | groupTitlesRequest.AgentData.RequestID; | ||
14911 | |||
14912 | List<GroupTitlesData> titles = | ||
14913 | m_GroupsModule.GroupTitlesRequest(this, | ||
14914 | groupTitlesRequest.AgentData.GroupID); | ||
14915 | |||
14916 | groupTitlesReply.GroupData = | ||
14917 | new GroupTitlesReplyPacket.GroupDataBlock[titles.Count]; | ||
14918 | |||
14919 | int i = 0; | ||
14920 | foreach (GroupTitlesData d in titles) | ||
14921 | { | ||
14922 | groupTitlesReply.GroupData[i] = | ||
14923 | new GroupTitlesReplyPacket.GroupDataBlock(); | ||
14924 | |||
14925 | groupTitlesReply.GroupData[i].Title = | ||
14926 | Util.StringToBytes256(d.Name); | ||
14927 | groupTitlesReply.GroupData[i].RoleID = | ||
14928 | d.UUID; | ||
14929 | groupTitlesReply.GroupData[i].Selected = | ||
14930 | d.Selected; | ||
14931 | i++; | ||
14932 | } | ||
14933 | |||
14934 | OutPacket(groupTitlesReply, ThrottleOutPacketType.Task); | ||
14935 | } | ||
14936 | break; | ||
14937 | |||
14938 | case PacketType.GroupProfileRequest: | ||
14939 | GroupProfileRequestPacket groupProfileRequest = | ||
14940 | (GroupProfileRequestPacket)Pack; | ||
14941 | |||
14942 | #region Packet Session and User Check | ||
14943 | if (m_checkPackets) | ||
14944 | { | ||
14945 | if (groupProfileRequest.AgentData.SessionID != SessionId || | ||
14946 | groupProfileRequest.AgentData.AgentID != AgentId) | ||
14947 | break; | ||
14948 | } | ||
14949 | #endregion | ||
14950 | |||
14951 | if (m_GroupsModule != null) | ||
14952 | { | ||
14953 | GroupProfileReplyPacket groupProfileReply = (GroupProfileReplyPacket)PacketPool.Instance.GetPacket(PacketType.GroupProfileReply); | ||
14954 | |||
14955 | groupProfileReply.AgentData = new GroupProfileReplyPacket.AgentDataBlock(); | ||
14956 | groupProfileReply.GroupData = new GroupProfileReplyPacket.GroupDataBlock(); | ||
14957 | groupProfileReply.AgentData.AgentID = AgentId; | ||
14958 | |||
14959 | GroupProfileData d = m_GroupsModule.GroupProfileRequest(this, | ||
14960 | groupProfileRequest.GroupData.GroupID); | ||
14961 | |||
14962 | groupProfileReply.GroupData.GroupID = d.GroupID; | ||
14963 | groupProfileReply.GroupData.Name = Util.StringToBytes256(d.Name); | ||
14964 | groupProfileReply.GroupData.Charter = Util.StringToBytes1024(d.Charter); | ||
14965 | groupProfileReply.GroupData.ShowInList = d.ShowInList; | ||
14966 | groupProfileReply.GroupData.MemberTitle = Util.StringToBytes256(d.MemberTitle); | ||
14967 | groupProfileReply.GroupData.PowersMask = d.PowersMask; | ||
14968 | groupProfileReply.GroupData.InsigniaID = d.InsigniaID; | ||
14969 | groupProfileReply.GroupData.FounderID = d.FounderID; | ||
14970 | groupProfileReply.GroupData.MembershipFee = d.MembershipFee; | ||
14971 | groupProfileReply.GroupData.OpenEnrollment = d.OpenEnrollment; | ||
14972 | groupProfileReply.GroupData.Money = d.Money; | ||
14973 | groupProfileReply.GroupData.GroupMembershipCount = d.GroupMembershipCount; | ||
14974 | groupProfileReply.GroupData.GroupRolesCount = d.GroupRolesCount; | ||
14975 | groupProfileReply.GroupData.AllowPublish = d.AllowPublish; | ||
14976 | groupProfileReply.GroupData.MaturePublish = d.MaturePublish; | ||
14977 | groupProfileReply.GroupData.OwnerRole = d.OwnerRole; | ||
14978 | |||
14979 | OutPacket(groupProfileReply, ThrottleOutPacketType.Task); | ||
14980 | } | ||
14981 | break; | ||
14982 | |||
14983 | case PacketType.GroupMembersRequest: | ||
14984 | GroupMembersRequestPacket groupMembersRequestPacket = | ||
14985 | (GroupMembersRequestPacket)Pack; | ||
14986 | |||
14987 | #region Packet Session and User Check | ||
14988 | if (m_checkPackets) | ||
14989 | { | ||
14990 | if (groupMembersRequestPacket.AgentData.SessionID != SessionId || | ||
14991 | groupMembersRequestPacket.AgentData.AgentID != AgentId) | ||
14992 | break; | ||
14993 | } | ||
14994 | #endregion | ||
14995 | |||
14996 | if (m_GroupsModule != null) | ||
14997 | { | ||
14998 | List<GroupMembersData> members = | ||
14999 | m_GroupsModule.GroupMembersRequest(this, groupMembersRequestPacket.GroupData.GroupID); | ||
15000 | |||
15001 | int memberCount = members.Count; | ||
15002 | |||
15003 | while (true) | ||
15004 | { | ||
15005 | int blockCount = members.Count; | ||
15006 | if (blockCount > 40) | ||
15007 | blockCount = 40; | ||
15008 | |||
15009 | GroupMembersReplyPacket groupMembersReply = (GroupMembersReplyPacket)PacketPool.Instance.GetPacket(PacketType.GroupMembersReply); | ||
15010 | |||
15011 | groupMembersReply.AgentData = | ||
15012 | new GroupMembersReplyPacket.AgentDataBlock(); | ||
15013 | groupMembersReply.GroupData = | ||
15014 | new GroupMembersReplyPacket.GroupDataBlock(); | ||
15015 | groupMembersReply.MemberData = | ||
15016 | new GroupMembersReplyPacket.MemberDataBlock[ | ||
15017 | blockCount]; | ||
15018 | |||
15019 | groupMembersReply.AgentData.AgentID = AgentId; | ||
15020 | groupMembersReply.GroupData.GroupID = | ||
15021 | groupMembersRequestPacket.GroupData.GroupID; | ||
15022 | groupMembersReply.GroupData.RequestID = | ||
15023 | groupMembersRequestPacket.GroupData.RequestID; | ||
15024 | groupMembersReply.GroupData.MemberCount = memberCount; | ||
15025 | |||
15026 | for (int i = 0; i < blockCount; i++) | ||
15027 | { | ||
15028 | GroupMembersData m = members[0]; | ||
15029 | members.RemoveAt(0); | ||
15030 | |||
15031 | groupMembersReply.MemberData[i] = | ||
15032 | new GroupMembersReplyPacket.MemberDataBlock(); | ||
15033 | groupMembersReply.MemberData[i].AgentID = | ||
15034 | m.AgentID; | ||
15035 | groupMembersReply.MemberData[i].Contribution = | ||
15036 | m.Contribution; | ||
15037 | groupMembersReply.MemberData[i].OnlineStatus = | ||
15038 | Util.StringToBytes256(m.OnlineStatus); | ||
15039 | groupMembersReply.MemberData[i].AgentPowers = | ||
15040 | m.AgentPowers; | ||
15041 | groupMembersReply.MemberData[i].Title = | ||
15042 | Util.StringToBytes256(m.Title); | ||
15043 | groupMembersReply.MemberData[i].IsOwner = | ||
15044 | m.IsOwner; | ||
15045 | } | ||
15046 | OutPacket(groupMembersReply, ThrottleOutPacketType.Task); | ||
15047 | if (members.Count == 0) | ||
15048 | break; | ||
15049 | } | ||
15050 | } | ||
15051 | break; | ||
15052 | |||
15053 | case PacketType.GroupRoleDataRequest: | ||
15054 | GroupRoleDataRequestPacket groupRolesRequest = | ||
15055 | (GroupRoleDataRequestPacket)Pack; | ||
15056 | |||
15057 | #region Packet Session and User Check | ||
15058 | if (m_checkPackets) | ||
15059 | { | ||
15060 | if (groupRolesRequest.AgentData.SessionID != SessionId || | ||
15061 | groupRolesRequest.AgentData.AgentID != AgentId) | ||
15062 | break; | ||
15063 | } | ||
15064 | #endregion | ||
15065 | |||
15066 | if (m_GroupsModule != null) | ||
15067 | { | ||
15068 | GroupRoleDataReplyPacket groupRolesReply = (GroupRoleDataReplyPacket)PacketPool.Instance.GetPacket(PacketType.GroupRoleDataReply); | ||
15069 | |||
15070 | groupRolesReply.AgentData = | ||
15071 | new GroupRoleDataReplyPacket.AgentDataBlock(); | ||
15072 | |||
15073 | groupRolesReply.AgentData.AgentID = AgentId; | ||
15074 | |||
15075 | groupRolesReply.GroupData = | ||
15076 | new GroupRoleDataReplyPacket.GroupDataBlock(); | ||
15077 | |||
15078 | groupRolesReply.GroupData.GroupID = | ||
15079 | groupRolesRequest.GroupData.GroupID; | ||
15080 | |||
15081 | groupRolesReply.GroupData.RequestID = | ||
15082 | groupRolesRequest.GroupData.RequestID; | ||
15083 | |||
15084 | List<GroupRolesData> titles = | ||
15085 | m_GroupsModule.GroupRoleDataRequest(this, | ||
15086 | groupRolesRequest.GroupData.GroupID); | ||
15087 | |||
15088 | groupRolesReply.GroupData.RoleCount = | ||
15089 | titles.Count; | ||
15090 | |||
15091 | groupRolesReply.RoleData = | ||
15092 | new GroupRoleDataReplyPacket.RoleDataBlock[titles.Count]; | ||
15093 | |||
15094 | int i = 0; | ||
15095 | foreach (GroupRolesData d in titles) | ||
15096 | { | ||
15097 | groupRolesReply.RoleData[i] = | ||
15098 | new GroupRoleDataReplyPacket.RoleDataBlock(); | ||
15099 | |||
15100 | groupRolesReply.RoleData[i].RoleID = | ||
15101 | d.RoleID; | ||
15102 | groupRolesReply.RoleData[i].Name = | ||
15103 | Util.StringToBytes256(d.Name); | ||
15104 | groupRolesReply.RoleData[i].Title = | ||
15105 | Util.StringToBytes256(d.Title); | ||
15106 | groupRolesReply.RoleData[i].Description = | ||
15107 | Util.StringToBytes1024(d.Description); | ||
15108 | groupRolesReply.RoleData[i].Powers = | ||
15109 | d.Powers; | ||
15110 | groupRolesReply.RoleData[i].Members = | ||
15111 | (uint)d.Members; | ||
15112 | |||
15113 | i++; | ||
15114 | } | ||
15115 | |||
15116 | OutPacket(groupRolesReply, ThrottleOutPacketType.Task); | ||
15117 | } | ||
15118 | break; | ||
15119 | |||
15120 | case PacketType.GroupRoleMembersRequest: | ||
15121 | GroupRoleMembersRequestPacket groupRoleMembersRequest = | ||
15122 | (GroupRoleMembersRequestPacket)Pack; | ||
15123 | |||
15124 | #region Packet Session and User Check | ||
15125 | if (m_checkPackets) | ||
15126 | { | ||
15127 | if (groupRoleMembersRequest.AgentData.SessionID != SessionId || | ||
15128 | groupRoleMembersRequest.AgentData.AgentID != AgentId) | ||
15129 | break; | ||
15130 | } | ||
15131 | #endregion | ||
15132 | |||
15133 | if (m_GroupsModule != null) | ||
15134 | { | ||
15135 | List<GroupRoleMembersData> mappings = | ||
15136 | m_GroupsModule.GroupRoleMembersRequest(this, | ||
15137 | groupRoleMembersRequest.GroupData.GroupID); | ||
15138 | |||
15139 | int mappingsCount = mappings.Count; | ||
15140 | |||
15141 | while (mappings.Count > 0) | ||
15142 | { | ||
15143 | int pairs = mappings.Count; | ||
15144 | if (pairs > 32) | ||
15145 | pairs = 32; | ||
15146 | |||
15147 | GroupRoleMembersReplyPacket groupRoleMembersReply = (GroupRoleMembersReplyPacket)PacketPool.Instance.GetPacket(PacketType.GroupRoleMembersReply); | ||
15148 | groupRoleMembersReply.AgentData = | ||
15149 | new GroupRoleMembersReplyPacket.AgentDataBlock(); | ||
15150 | groupRoleMembersReply.AgentData.AgentID = | ||
15151 | AgentId; | ||
15152 | groupRoleMembersReply.AgentData.GroupID = | ||
15153 | groupRoleMembersRequest.GroupData.GroupID; | ||
15154 | groupRoleMembersReply.AgentData.RequestID = | ||
15155 | groupRoleMembersRequest.GroupData.RequestID; | ||
15156 | |||
15157 | groupRoleMembersReply.AgentData.TotalPairs = | ||
15158 | (uint)mappingsCount; | ||
15159 | |||
15160 | groupRoleMembersReply.MemberData = | ||
15161 | new GroupRoleMembersReplyPacket.MemberDataBlock[pairs]; | ||
15162 | |||
15163 | for (int i = 0; i < pairs; i++) | ||
15164 | { | ||
15165 | GroupRoleMembersData d = mappings[0]; | ||
15166 | mappings.RemoveAt(0); | ||
15167 | |||
15168 | groupRoleMembersReply.MemberData[i] = | ||
15169 | new GroupRoleMembersReplyPacket.MemberDataBlock(); | ||
15170 | |||
15171 | groupRoleMembersReply.MemberData[i].RoleID = | ||
15172 | d.RoleID; | ||
15173 | groupRoleMembersReply.MemberData[i].MemberID = | ||
15174 | d.MemberID; | ||
15175 | } | ||
15176 | |||
15177 | OutPacket(groupRoleMembersReply, ThrottleOutPacketType.Task); | ||
15178 | } | ||
15179 | } | ||
15180 | break; | ||
15181 | |||
15182 | case PacketType.CreateGroupRequest: | ||
15183 | CreateGroupRequestPacket createGroupRequest = | ||
15184 | (CreateGroupRequestPacket)Pack; | ||
15185 | |||
15186 | #region Packet Session and User Check | ||
15187 | if (m_checkPackets) | ||
15188 | { | ||
15189 | if (createGroupRequest.AgentData.SessionID != SessionId || | ||
15190 | createGroupRequest.AgentData.AgentID != AgentId) | ||
15191 | break; | ||
15192 | } | ||
15193 | #endregion | ||
15194 | |||
15195 | if (m_GroupsModule != null) | ||
15196 | { | ||
15197 | m_GroupsModule.CreateGroup(this, | ||
15198 | Utils.BytesToString(createGroupRequest.GroupData.Name), | ||
15199 | Utils.BytesToString(createGroupRequest.GroupData.Charter), | ||
15200 | createGroupRequest.GroupData.ShowInList, | ||
15201 | createGroupRequest.GroupData.InsigniaID, | ||
15202 | createGroupRequest.GroupData.MembershipFee, | ||
15203 | createGroupRequest.GroupData.OpenEnrollment, | ||
15204 | createGroupRequest.GroupData.AllowPublish, | ||
15205 | createGroupRequest.GroupData.MaturePublish); | ||
15206 | } | ||
15207 | break; | ||
15208 | |||
15209 | case PacketType.UpdateGroupInfo: | ||
15210 | UpdateGroupInfoPacket updateGroupInfo = | ||
15211 | (UpdateGroupInfoPacket)Pack; | ||
15212 | |||
15213 | #region Packet Session and User Check | ||
15214 | if (m_checkPackets) | ||
15215 | { | ||
15216 | if (updateGroupInfo.AgentData.SessionID != SessionId || | ||
15217 | updateGroupInfo.AgentData.AgentID != AgentId) | ||
15218 | break; | ||
15219 | } | ||
15220 | #endregion | ||
15221 | |||
15222 | if (m_GroupsModule != null) | ||
15223 | { | ||
15224 | m_GroupsModule.UpdateGroupInfo(this, | ||
15225 | updateGroupInfo.GroupData.GroupID, | ||
15226 | Utils.BytesToString(updateGroupInfo.GroupData.Charter), | ||
15227 | updateGroupInfo.GroupData.ShowInList, | ||
15228 | updateGroupInfo.GroupData.InsigniaID, | ||
15229 | updateGroupInfo.GroupData.MembershipFee, | ||
15230 | updateGroupInfo.GroupData.OpenEnrollment, | ||
15231 | updateGroupInfo.GroupData.AllowPublish, | ||
15232 | updateGroupInfo.GroupData.MaturePublish); | ||
15233 | } | ||
15234 | |||
15235 | break; | ||
15236 | |||
15237 | case PacketType.SetGroupAcceptNotices: | ||
15238 | SetGroupAcceptNoticesPacket setGroupAcceptNotices = | ||
15239 | (SetGroupAcceptNoticesPacket)Pack; | ||
15240 | |||
15241 | #region Packet Session and User Check | ||
15242 | if (m_checkPackets) | ||
15243 | { | ||
15244 | if (setGroupAcceptNotices.AgentData.SessionID != SessionId || | ||
15245 | setGroupAcceptNotices.AgentData.AgentID != AgentId) | ||
15246 | break; | ||
15247 | } | ||
15248 | #endregion | ||
15249 | |||
15250 | if (m_GroupsModule != null) | ||
15251 | { | ||
15252 | m_GroupsModule.SetGroupAcceptNotices(this, | ||
15253 | setGroupAcceptNotices.Data.GroupID, | ||
15254 | setGroupAcceptNotices.Data.AcceptNotices, | ||
15255 | setGroupAcceptNotices.NewData.ListInProfile); | ||
15256 | } | ||
15257 | |||
15258 | break; | ||
15259 | |||
15260 | case PacketType.GroupTitleUpdate: | ||
15261 | GroupTitleUpdatePacket groupTitleUpdate = | ||
15262 | (GroupTitleUpdatePacket)Pack; | ||
15263 | |||
15264 | #region Packet Session and User Check | ||
15265 | if (m_checkPackets) | ||
15266 | { | ||
15267 | if (groupTitleUpdate.AgentData.SessionID != SessionId || | ||
15268 | groupTitleUpdate.AgentData.AgentID != AgentId) | ||
15269 | break; | ||
15270 | } | ||
15271 | #endregion | ||
15272 | |||
15273 | if (m_GroupsModule != null) | ||
15274 | { | ||
15275 | m_GroupsModule.GroupTitleUpdate(this, | ||
15276 | groupTitleUpdate.AgentData.GroupID, | ||
15277 | groupTitleUpdate.AgentData.TitleRoleID); | ||
15278 | } | ||
15279 | |||
15280 | break; | ||
15281 | |||
15282 | |||
15283 | case PacketType.ParcelDeedToGroup: | ||
15284 | ParcelDeedToGroupPacket parcelDeedToGroup = (ParcelDeedToGroupPacket)Pack; | ||
15285 | if (m_GroupsModule != null) | ||
15286 | { | ||
15287 | ParcelDeedToGroup handlerParcelDeedToGroup = OnParcelDeedToGroup; | ||
15288 | if (handlerParcelDeedToGroup != null) | ||
15289 | { | ||
15290 | handlerParcelDeedToGroup(parcelDeedToGroup.Data.LocalID, parcelDeedToGroup.Data.GroupID, this); | ||
15291 | |||
15292 | } | ||
15293 | } | ||
15294 | |||
15295 | break; | ||
15296 | |||
15297 | |||
15298 | case PacketType.GroupNoticesListRequest: | ||
15299 | GroupNoticesListRequestPacket groupNoticesListRequest = | ||
15300 | (GroupNoticesListRequestPacket)Pack; | ||
15301 | |||
15302 | #region Packet Session and User Check | ||
15303 | if (m_checkPackets) | ||
15304 | { | ||
15305 | if (groupNoticesListRequest.AgentData.SessionID != SessionId || | ||
15306 | groupNoticesListRequest.AgentData.AgentID != AgentId) | ||
15307 | break; | ||
15308 | } | ||
15309 | #endregion | ||
15310 | |||
15311 | if (m_GroupsModule != null) | ||
15312 | { | ||
15313 | GroupNoticeData[] gn = | ||
15314 | m_GroupsModule.GroupNoticesListRequest(this, | ||
15315 | groupNoticesListRequest.Data.GroupID); | ||
15316 | |||
15317 | GroupNoticesListReplyPacket groupNoticesListReply = (GroupNoticesListReplyPacket)PacketPool.Instance.GetPacket(PacketType.GroupNoticesListReply); | ||
15318 | groupNoticesListReply.AgentData = | ||
15319 | new GroupNoticesListReplyPacket.AgentDataBlock(); | ||
15320 | groupNoticesListReply.AgentData.AgentID = AgentId; | ||
15321 | groupNoticesListReply.AgentData.GroupID = groupNoticesListRequest.Data.GroupID; | ||
15322 | |||
15323 | groupNoticesListReply.Data = new GroupNoticesListReplyPacket.DataBlock[gn.Length]; | ||
15324 | |||
15325 | int i = 0; | ||
15326 | foreach (GroupNoticeData g in gn) | ||
15327 | { | ||
15328 | groupNoticesListReply.Data[i] = new GroupNoticesListReplyPacket.DataBlock(); | ||
15329 | groupNoticesListReply.Data[i].NoticeID = | ||
15330 | g.NoticeID; | ||
15331 | groupNoticesListReply.Data[i].Timestamp = | ||
15332 | g.Timestamp; | ||
15333 | groupNoticesListReply.Data[i].FromName = | ||
15334 | Util.StringToBytes256(g.FromName); | ||
15335 | groupNoticesListReply.Data[i].Subject = | ||
15336 | Util.StringToBytes256(g.Subject); | ||
15337 | groupNoticesListReply.Data[i].HasAttachment = | ||
15338 | g.HasAttachment; | ||
15339 | groupNoticesListReply.Data[i].AssetType = | ||
15340 | g.AssetType; | ||
15341 | i++; | ||
15342 | } | ||
15343 | |||
15344 | OutPacket(groupNoticesListReply, ThrottleOutPacketType.Task); | ||
15345 | } | ||
15346 | |||
15347 | break; | ||
15348 | |||
15349 | case PacketType.GroupNoticeRequest: | ||
15350 | GroupNoticeRequestPacket groupNoticeRequest = | ||
15351 | (GroupNoticeRequestPacket)Pack; | ||
15352 | |||
15353 | #region Packet Session and User Check | ||
15354 | if (m_checkPackets) | ||
15355 | { | ||
15356 | if (groupNoticeRequest.AgentData.SessionID != SessionId || | ||
15357 | groupNoticeRequest.AgentData.AgentID != AgentId) | ||
15358 | break; | ||
15359 | } | ||
15360 | #endregion | ||
15361 | |||
15362 | if (m_GroupsModule != null) | ||
15363 | { | ||
15364 | m_GroupsModule.GroupNoticeRequest(this, | ||
15365 | groupNoticeRequest.Data.GroupNoticeID); | ||
15366 | } | ||
15367 | break; | ||
15368 | |||
15369 | case PacketType.GroupRoleUpdate: | ||
15370 | GroupRoleUpdatePacket groupRoleUpdate = | ||
15371 | (GroupRoleUpdatePacket)Pack; | ||
15372 | |||
15373 | #region Packet Session and User Check | ||
15374 | if (m_checkPackets) | ||
15375 | { | ||
15376 | if (groupRoleUpdate.AgentData.SessionID != SessionId || | ||
15377 | groupRoleUpdate.AgentData.AgentID != AgentId) | ||
15378 | break; | ||
15379 | } | ||
15380 | #endregion | ||
15381 | |||
15382 | if (m_GroupsModule != null) | ||
15383 | { | ||
15384 | foreach (GroupRoleUpdatePacket.RoleDataBlock d in | ||
15385 | groupRoleUpdate.RoleData) | ||
15386 | { | ||
15387 | m_GroupsModule.GroupRoleUpdate(this, | ||
15388 | groupRoleUpdate.AgentData.GroupID, | ||
15389 | d.RoleID, | ||
15390 | Utils.BytesToString(d.Name), | ||
15391 | Utils.BytesToString(d.Description), | ||
15392 | Utils.BytesToString(d.Title), | ||
15393 | d.Powers, | ||
15394 | d.UpdateType); | ||
15395 | } | ||
15396 | m_GroupsModule.NotifyChange(groupRoleUpdate.AgentData.GroupID); | ||
15397 | } | ||
15398 | break; | ||
15399 | |||
15400 | case PacketType.GroupRoleChanges: | ||
15401 | GroupRoleChangesPacket groupRoleChanges = | ||
15402 | (GroupRoleChangesPacket)Pack; | ||
15403 | |||
15404 | #region Packet Session and User Check | ||
15405 | if (m_checkPackets) | ||
15406 | { | ||
15407 | if (groupRoleChanges.AgentData.SessionID != SessionId || | ||
15408 | groupRoleChanges.AgentData.AgentID != AgentId) | ||
15409 | break; | ||
15410 | } | ||
15411 | #endregion | ||
15412 | |||
15413 | if (m_GroupsModule != null) | ||
15414 | { | ||
15415 | foreach (GroupRoleChangesPacket.RoleChangeBlock d in | ||
15416 | groupRoleChanges.RoleChange) | ||
15417 | { | ||
15418 | m_GroupsModule.GroupRoleChanges(this, | ||
15419 | groupRoleChanges.AgentData.GroupID, | ||
15420 | d.RoleID, | ||
15421 | d.MemberID, | ||
15422 | d.Change); | ||
15423 | } | ||
15424 | m_GroupsModule.NotifyChange(groupRoleChanges.AgentData.GroupID); | ||
15425 | } | ||
15426 | break; | ||
15427 | |||
15428 | case PacketType.JoinGroupRequest: | ||
15429 | JoinGroupRequestPacket joinGroupRequest = | ||
15430 | (JoinGroupRequestPacket)Pack; | ||
15431 | |||
15432 | #region Packet Session and User Check | ||
15433 | if (m_checkPackets) | ||
15434 | { | ||
15435 | if (joinGroupRequest.AgentData.SessionID != SessionId || | ||
15436 | joinGroupRequest.AgentData.AgentID != AgentId) | ||
15437 | break; | ||
15438 | } | ||
15439 | #endregion | ||
15440 | |||
15441 | if (m_GroupsModule != null) | ||
15442 | { | ||
15443 | m_GroupsModule.JoinGroupRequest(this, | ||
15444 | joinGroupRequest.GroupData.GroupID); | ||
15445 | } | ||
15446 | break; | ||
15447 | |||
15448 | case PacketType.LeaveGroupRequest: | ||
15449 | LeaveGroupRequestPacket leaveGroupRequest = | ||
15450 | (LeaveGroupRequestPacket)Pack; | ||
15451 | |||
15452 | #region Packet Session and User Check | ||
15453 | if (m_checkPackets) | ||
15454 | { | ||
15455 | if (leaveGroupRequest.AgentData.SessionID != SessionId || | ||
15456 | leaveGroupRequest.AgentData.AgentID != AgentId) | ||
15457 | break; | ||
15458 | } | ||
15459 | #endregion | ||
15460 | |||
15461 | if (m_GroupsModule != null) | ||
15462 | { | ||
15463 | m_GroupsModule.LeaveGroupRequest(this, | ||
15464 | leaveGroupRequest.GroupData.GroupID); | ||
15465 | } | ||
15466 | break; | ||
15467 | |||
15468 | case PacketType.EjectGroupMemberRequest: | ||
15469 | EjectGroupMemberRequestPacket ejectGroupMemberRequest = | ||
15470 | (EjectGroupMemberRequestPacket)Pack; | ||
15471 | |||
15472 | #region Packet Session and User Check | ||
15473 | if (m_checkPackets) | ||
15474 | { | ||
15475 | if (ejectGroupMemberRequest.AgentData.SessionID != SessionId || | ||
15476 | ejectGroupMemberRequest.AgentData.AgentID != AgentId) | ||
15477 | break; | ||
15478 | } | ||
15479 | #endregion | ||
15480 | |||
15481 | if (m_GroupsModule != null) | ||
15482 | { | ||
15483 | foreach (EjectGroupMemberRequestPacket.EjectDataBlock e | ||
15484 | in ejectGroupMemberRequest.EjectData) | ||
15485 | { | ||
15486 | m_GroupsModule.EjectGroupMemberRequest(this, | ||
15487 | ejectGroupMemberRequest.GroupData.GroupID, | ||
15488 | e.EjecteeID); | ||
15489 | } | ||
15490 | } | ||
15491 | break; | ||
15492 | |||
15493 | case PacketType.InviteGroupRequest: | ||
15494 | InviteGroupRequestPacket inviteGroupRequest = | ||
15495 | (InviteGroupRequestPacket)Pack; | ||
15496 | |||
15497 | #region Packet Session and User Check | ||
15498 | if (m_checkPackets) | ||
15499 | { | ||
15500 | if (inviteGroupRequest.AgentData.SessionID != SessionId || | ||
15501 | inviteGroupRequest.AgentData.AgentID != AgentId) | ||
15502 | break; | ||
15503 | } | ||
15504 | #endregion | ||
15505 | |||
15506 | if (m_GroupsModule != null) | ||
15507 | { | ||
15508 | foreach (InviteGroupRequestPacket.InviteDataBlock b in | ||
15509 | inviteGroupRequest.InviteData) | ||
15510 | { | ||
15511 | m_GroupsModule.InviteGroupRequest(this, | ||
15512 | inviteGroupRequest.GroupData.GroupID, | ||
15513 | b.InviteeID, | ||
15514 | b.RoleID); | ||
15515 | } | ||
15516 | } | ||
15517 | break; | ||
15518 | |||
15519 | //#endregion | ||
15520 | |||
15521 | case PacketType.StartLure: | ||
15522 | StartLurePacket startLureRequest = (StartLurePacket)Pack; | ||
15523 | |||
15524 | #region Packet Session and User Check | ||
15525 | if (m_checkPackets) | ||
15526 | { | ||
15527 | if (startLureRequest.AgentData.SessionID != SessionId || | ||
15528 | startLureRequest.AgentData.AgentID != AgentId) | ||
15529 | break; | ||
15530 | } | ||
15531 | #endregion | ||
15532 | |||
15533 | StartLure handlerStartLure = OnStartLure; | ||
15534 | if (handlerStartLure != null) | ||
15535 | handlerStartLure(startLureRequest.Info.LureType, | ||
15536 | Utils.BytesToString( | ||
15537 | startLureRequest.Info.Message), | ||
15538 | startLureRequest.TargetData[0].TargetID, | ||
15539 | this); | ||
15540 | break; | ||
15541 | |||
15542 | case PacketType.TeleportLureRequest: | ||
15543 | TeleportLureRequestPacket teleportLureRequest = | ||
15544 | (TeleportLureRequestPacket)Pack; | ||
15545 | |||
15546 | #region Packet Session and User Check | ||
15547 | if (m_checkPackets) | ||
15548 | { | ||
15549 | if (teleportLureRequest.Info.SessionID != SessionId || | ||
15550 | teleportLureRequest.Info.AgentID != AgentId) | ||
15551 | break; | ||
15552 | } | ||
15553 | #endregion | ||
15554 | |||
15555 | TeleportLureRequest handlerTeleportLureRequest = OnTeleportLureRequest; | ||
15556 | if (handlerTeleportLureRequest != null) | ||
15557 | handlerTeleportLureRequest( | ||
15558 | teleportLureRequest.Info.LureID, | ||
15559 | teleportLureRequest.Info.TeleportFlags, | ||
15560 | this); | ||
15561 | break; | ||
15562 | |||
15563 | case PacketType.ClassifiedInfoRequest: | ||
15564 | ClassifiedInfoRequestPacket classifiedInfoRequest = | ||
15565 | (ClassifiedInfoRequestPacket)Pack; | ||
15566 | |||
15567 | #region Packet Session and User Check | ||
15568 | if (m_checkPackets) | ||
15569 | { | ||
15570 | if (classifiedInfoRequest.AgentData.SessionID != SessionId || | ||
15571 | classifiedInfoRequest.AgentData.AgentID != AgentId) | ||
15572 | break; | ||
15573 | } | ||
15574 | #endregion | ||
15575 | |||
15576 | ClassifiedInfoRequest handlerClassifiedInfoRequest = OnClassifiedInfoRequest; | ||
15577 | if (handlerClassifiedInfoRequest != null) | ||
15578 | handlerClassifiedInfoRequest( | ||
15579 | classifiedInfoRequest.Data.ClassifiedID, | ||
15580 | this); | ||
15581 | break; | ||
15582 | |||
15583 | case PacketType.ClassifiedInfoUpdate: | ||
15584 | ClassifiedInfoUpdatePacket classifiedInfoUpdate = | ||
15585 | (ClassifiedInfoUpdatePacket)Pack; | ||
15586 | |||
15587 | #region Packet Session and User Check | ||
15588 | if (m_checkPackets) | ||
15589 | { | ||
15590 | if (classifiedInfoUpdate.AgentData.SessionID != SessionId || | ||
15591 | classifiedInfoUpdate.AgentData.AgentID != AgentId) | ||
15592 | break; | ||
15593 | } | ||
15594 | #endregion | ||
15595 | |||
15596 | ClassifiedInfoUpdate handlerClassifiedInfoUpdate = OnClassifiedInfoUpdate; | ||
15597 | if (handlerClassifiedInfoUpdate != null) | ||
15598 | handlerClassifiedInfoUpdate( | ||
15599 | classifiedInfoUpdate.Data.ClassifiedID, | ||
15600 | classifiedInfoUpdate.Data.Category, | ||
15601 | Utils.BytesToString( | ||
15602 | classifiedInfoUpdate.Data.Name), | ||
15603 | Utils.BytesToString( | ||
15604 | classifiedInfoUpdate.Data.Desc), | ||
15605 | classifiedInfoUpdate.Data.ParcelID, | ||
15606 | classifiedInfoUpdate.Data.ParentEstate, | ||
15607 | classifiedInfoUpdate.Data.SnapshotID, | ||
15608 | new Vector3( | ||
15609 | classifiedInfoUpdate.Data.PosGlobal), | ||
15610 | classifiedInfoUpdate.Data.ClassifiedFlags, | ||
15611 | classifiedInfoUpdate.Data.PriceForListing, | ||
15612 | this); | ||
15613 | break; | ||
15614 | |||
15615 | case PacketType.ClassifiedDelete: | ||
15616 | ClassifiedDeletePacket classifiedDelete = | ||
15617 | (ClassifiedDeletePacket)Pack; | ||
15618 | |||
15619 | #region Packet Session and User Check | ||
15620 | if (m_checkPackets) | ||
15621 | { | ||
15622 | if (classifiedDelete.AgentData.SessionID != SessionId || | ||
15623 | classifiedDelete.AgentData.AgentID != AgentId) | ||
15624 | break; | ||
15625 | } | ||
15626 | #endregion | ||
15627 | |||
15628 | ClassifiedDelete handlerClassifiedDelete = OnClassifiedDelete; | ||
15629 | if (handlerClassifiedDelete != null) | ||
15630 | handlerClassifiedDelete( | ||
15631 | classifiedDelete.Data.ClassifiedID, | ||
15632 | this); | ||
15633 | break; | ||
15634 | |||
15635 | case PacketType.ClassifiedGodDelete: | ||
15636 | ClassifiedGodDeletePacket classifiedGodDelete = | ||
15637 | (ClassifiedGodDeletePacket)Pack; | ||
15638 | |||
15639 | #region Packet Session and User Check | ||
15640 | if (m_checkPackets) | ||
15641 | { | ||
15642 | if (classifiedGodDelete.AgentData.SessionID != SessionId || | ||
15643 | classifiedGodDelete.AgentData.AgentID != AgentId) | ||
15644 | break; | ||
15645 | } | ||
15646 | #endregion | ||
15647 | |||
15648 | ClassifiedDelete handlerClassifiedGodDelete = OnClassifiedGodDelete; | ||
15649 | if (handlerClassifiedGodDelete != null) | ||
15650 | handlerClassifiedGodDelete( | ||
15651 | classifiedGodDelete.Data.ClassifiedID, | ||
15652 | this); | ||
15653 | break; | ||
15654 | |||
15655 | case PacketType.EventGodDelete: | ||
15656 | EventGodDeletePacket eventGodDelete = | ||
15657 | (EventGodDeletePacket)Pack; | ||
15658 | |||
15659 | #region Packet Session and User Check | ||
15660 | if (m_checkPackets) | ||
15661 | { | ||
15662 | if (eventGodDelete.AgentData.SessionID != SessionId || | ||
15663 | eventGodDelete.AgentData.AgentID != AgentId) | ||
15664 | break; | ||
15665 | } | ||
15666 | #endregion | ||
15667 | |||
15668 | EventGodDelete handlerEventGodDelete = OnEventGodDelete; | ||
15669 | if (handlerEventGodDelete != null) | ||
15670 | handlerEventGodDelete( | ||
15671 | eventGodDelete.EventData.EventID, | ||
15672 | eventGodDelete.QueryData.QueryID, | ||
15673 | Utils.BytesToString( | ||
15674 | eventGodDelete.QueryData.QueryText), | ||
15675 | eventGodDelete.QueryData.QueryFlags, | ||
15676 | eventGodDelete.QueryData.QueryStart, | ||
15677 | this); | ||
15678 | break; | ||
15679 | |||
15680 | case PacketType.EventNotificationAddRequest: | ||
15681 | EventNotificationAddRequestPacket eventNotificationAdd = | ||
15682 | (EventNotificationAddRequestPacket)Pack; | ||
15683 | |||
15684 | #region Packet Session and User Check | ||
15685 | if (m_checkPackets) | ||
15686 | { | ||
15687 | if (eventNotificationAdd.AgentData.SessionID != SessionId || | ||
15688 | eventNotificationAdd.AgentData.AgentID != AgentId) | ||
15689 | break; | ||
15690 | } | ||
15691 | #endregion | ||
15692 | |||
15693 | EventNotificationAddRequest handlerEventNotificationAddRequest = OnEventNotificationAddRequest; | ||
15694 | if (handlerEventNotificationAddRequest != null) | ||
15695 | handlerEventNotificationAddRequest( | ||
15696 | eventNotificationAdd.EventData.EventID, this); | ||
15697 | break; | ||
15698 | |||
15699 | case PacketType.EventNotificationRemoveRequest: | ||
15700 | EventNotificationRemoveRequestPacket eventNotificationRemove = | ||
15701 | (EventNotificationRemoveRequestPacket)Pack; | ||
15702 | |||
15703 | #region Packet Session and User Check | ||
15704 | if (m_checkPackets) | ||
15705 | { | ||
15706 | if (eventNotificationRemove.AgentData.SessionID != SessionId || | ||
15707 | eventNotificationRemove.AgentData.AgentID != AgentId) | ||
15708 | break; | ||
15709 | } | ||
15710 | #endregion | ||
15711 | |||
15712 | EventNotificationRemoveRequest handlerEventNotificationRemoveRequest = OnEventNotificationRemoveRequest; | ||
15713 | if (handlerEventNotificationRemoveRequest != null) | ||
15714 | handlerEventNotificationRemoveRequest( | ||
15715 | eventNotificationRemove.EventData.EventID, this); | ||
15716 | break; | ||
15717 | |||
15718 | case PacketType.RetrieveInstantMessages: | ||
15719 | RetrieveInstantMessagesPacket rimpInstantMessagePack = (RetrieveInstantMessagesPacket)Pack; | ||
15720 | |||
15721 | #region Packet Session and User Check | ||
15722 | if (m_checkPackets) | ||
15723 | { | ||
15724 | if (rimpInstantMessagePack.AgentData.SessionID != SessionId || | ||
15725 | rimpInstantMessagePack.AgentData.AgentID != AgentId) | ||
15726 | break; | ||
15727 | } | ||
15728 | #endregion | ||
15729 | |||
15730 | RetrieveInstantMessages handlerRetrieveInstantMessages = OnRetrieveInstantMessages; | ||
15731 | if (handlerRetrieveInstantMessages != null) | ||
15732 | handlerRetrieveInstantMessages(this); | ||
15733 | break; | ||
15734 | |||
15735 | case PacketType.PickDelete: | ||
15736 | PickDeletePacket pickDelete = | ||
15737 | (PickDeletePacket)Pack; | ||
15738 | |||
15739 | #region Packet Session and User Check | ||
15740 | if (m_checkPackets) | ||
15741 | { | ||
15742 | if (pickDelete.AgentData.SessionID != SessionId || | ||
15743 | pickDelete.AgentData.AgentID != AgentId) | ||
15744 | break; | ||
15745 | } | ||
15746 | #endregion | ||
15747 | |||
15748 | PickDelete handlerPickDelete = OnPickDelete; | ||
15749 | if (handlerPickDelete != null) | ||
15750 | handlerPickDelete(this, pickDelete.Data.PickID); | ||
15751 | break; | ||
15752 | |||
15753 | case PacketType.PickGodDelete: | ||
15754 | PickGodDeletePacket pickGodDelete = | ||
15755 | (PickGodDeletePacket)Pack; | ||
15756 | |||
15757 | #region Packet Session and User Check | ||
15758 | if (m_checkPackets) | ||
15759 | { | ||
15760 | if (pickGodDelete.AgentData.SessionID != SessionId || | ||
15761 | pickGodDelete.AgentData.AgentID != AgentId) | ||
15762 | break; | ||
15763 | } | ||
15764 | #endregion | ||
15765 | |||
15766 | PickGodDelete handlerPickGodDelete = OnPickGodDelete; | ||
15767 | if (handlerPickGodDelete != null) | ||
15768 | handlerPickGodDelete(this, | ||
15769 | pickGodDelete.AgentData.AgentID, | ||
15770 | pickGodDelete.Data.PickID, | ||
15771 | pickGodDelete.Data.QueryID); | ||
15772 | break; | ||
15773 | |||
15774 | case PacketType.PickInfoUpdate: | ||
15775 | PickInfoUpdatePacket pickInfoUpdate = | ||
15776 | (PickInfoUpdatePacket)Pack; | ||
15777 | |||
15778 | #region Packet Session and User Check | ||
15779 | if (m_checkPackets) | ||
15780 | { | ||
15781 | if (pickInfoUpdate.AgentData.SessionID != SessionId || | ||
15782 | pickInfoUpdate.AgentData.AgentID != AgentId) | ||
15783 | break; | ||
15784 | } | ||
15785 | #endregion | ||
15786 | |||
15787 | PickInfoUpdate handlerPickInfoUpdate = OnPickInfoUpdate; | ||
15788 | if (handlerPickInfoUpdate != null) | ||
15789 | handlerPickInfoUpdate(this, | ||
15790 | pickInfoUpdate.Data.PickID, | ||
15791 | pickInfoUpdate.Data.CreatorID, | ||
15792 | pickInfoUpdate.Data.TopPick, | ||
15793 | Utils.BytesToString(pickInfoUpdate.Data.Name), | ||
15794 | Utils.BytesToString(pickInfoUpdate.Data.Desc), | ||
15795 | pickInfoUpdate.Data.SnapshotID, | ||
15796 | pickInfoUpdate.Data.SortOrder, | ||
15797 | pickInfoUpdate.Data.Enabled); | ||
15798 | break; | ||
15799 | |||
15800 | case PacketType.AvatarNotesUpdate: | ||
15801 | AvatarNotesUpdatePacket avatarNotesUpdate = | ||
15802 | (AvatarNotesUpdatePacket)Pack; | ||
15803 | |||
15804 | #region Packet Session and User Check | ||
15805 | if (m_checkPackets) | ||
15806 | { | ||
15807 | if (avatarNotesUpdate.AgentData.SessionID != SessionId || | ||
15808 | avatarNotesUpdate.AgentData.AgentID != AgentId) | ||
15809 | break; | ||
15810 | } | ||
15811 | #endregion | ||
15812 | |||
15813 | AvatarNotesUpdate handlerAvatarNotesUpdate = OnAvatarNotesUpdate; | ||
15814 | if (handlerAvatarNotesUpdate != null) | ||
15815 | handlerAvatarNotesUpdate(this, | ||
15816 | avatarNotesUpdate.Data.TargetID, | ||
15817 | Utils.BytesToString(avatarNotesUpdate.Data.Notes)); | ||
15818 | break; | ||
15819 | |||
15820 | case PacketType.AvatarInterestsUpdate: | ||
15821 | AvatarInterestsUpdatePacket avatarInterestUpdate = | ||
15822 | (AvatarInterestsUpdatePacket)Pack; | ||
15823 | |||
15824 | #region Packet Session and User Check | ||
15825 | if (m_checkPackets) | ||
15826 | { | ||
15827 | if (avatarInterestUpdate.AgentData.SessionID != SessionId || | ||
15828 | avatarInterestUpdate.AgentData.AgentID != AgentId) | ||
15829 | break; | ||
15830 | } | ||
15831 | #endregion | ||
15832 | 11040 | ||
15833 | AvatarInterestUpdate handlerAvatarInterestUpdate = OnAvatarInterestUpdate; | 11041 | if (!ProcessPacketMethod(Pack)) |
15834 | if (handlerAvatarInterestUpdate != null) | 11042 | m_log.Warn("[CLIENT]: unhandled packet " + Pack); |
15835 | handlerAvatarInterestUpdate(this, | ||
15836 | avatarInterestUpdate.PropertiesData.WantToMask, | ||
15837 | Utils.BytesToString(avatarInterestUpdate.PropertiesData.WantToText), | ||
15838 | avatarInterestUpdate.PropertiesData.SkillsMask, | ||
15839 | Utils.BytesToString(avatarInterestUpdate.PropertiesData.SkillsText), | ||
15840 | Utils.BytesToString(avatarInterestUpdate.PropertiesData.LanguagesText)); | ||
15841 | break; | ||
15842 | |||
15843 | case PacketType.GrantUserRights: | ||
15844 | GrantUserRightsPacket GrantUserRights = | ||
15845 | (GrantUserRightsPacket)Pack; | ||
15846 | #region Packet Session and User Check | ||
15847 | if (m_checkPackets) | ||
15848 | { | ||
15849 | if (GrantUserRights.AgentData.SessionID != SessionId || | ||
15850 | GrantUserRights.AgentData.AgentID != AgentId) | ||
15851 | break; | ||
15852 | } | ||
15853 | #endregion | ||
15854 | GrantUserFriendRights GrantUserRightsHandler = OnGrantUserRights; | ||
15855 | if (GrantUserRightsHandler != null) | ||
15856 | GrantUserRightsHandler(this, | ||
15857 | GrantUserRights.AgentData.AgentID, | ||
15858 | GrantUserRights.Rights[0].AgentRelated, | ||
15859 | GrantUserRights.Rights[0].RelatedRights); | ||
15860 | break; | ||
15861 | |||
15862 | case PacketType.PlacesQuery: | ||
15863 | PlacesQueryPacket placesQueryPacket = | ||
15864 | (PlacesQueryPacket)Pack; | ||
15865 | |||
15866 | PlacesQuery handlerPlacesQuery = OnPlacesQuery; | ||
15867 | |||
15868 | if (handlerPlacesQuery != null) | ||
15869 | handlerPlacesQuery(placesQueryPacket.AgentData.QueryID, | ||
15870 | placesQueryPacket.TransactionData.TransactionID, | ||
15871 | Utils.BytesToString( | ||
15872 | placesQueryPacket.QueryData.QueryText), | ||
15873 | placesQueryPacket.QueryData.QueryFlags, | ||
15874 | (byte)placesQueryPacket.QueryData.Category, | ||
15875 | Utils.BytesToString( | ||
15876 | placesQueryPacket.QueryData.SimName), | ||
15877 | this); | ||
15878 | break; | ||
15879 | */ | ||
15880 | #endregion | ||
15881 | default: | ||
15882 | m_log.Warn("[CLIENT]: unhandled packet " + Pack); | ||
15883 | break; | ||
15884 | } | ||
15885 | 11043 | ||
15886 | PacketPool.Instance.ReturnPacket(Pack); | 11044 | PacketPool.Instance.ReturnPacket(Pack); |
15887 | |||
15888 | } | 11045 | } |
15889 | 11046 | ||
15890 | private static PrimitiveBaseShape GetShapeFromAddPacket(ObjectAddPacket addPacket) | 11047 | private static PrimitiveBaseShape GetShapeFromAddPacket(ObjectAddPacket addPacket) |
diff --git a/OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs b/OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs index 1903eb9..b1b7b27 100644 --- a/OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs +++ b/OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs | |||
@@ -330,7 +330,7 @@ namespace OpenSim.Region.CoreModules.Asset | |||
330 | //m_log.DebugFormat("[XXX] name = {0} (this module's name: {1}", name, Name); | 330 | //m_log.DebugFormat("[XXX] name = {0} (this module's name: {1}", name, Name); |
331 | 331 | ||
332 | if (name != Name) | 332 | if (name != Name) |
333 | return; | 333 | return; |
334 | 334 | ||
335 | long maxSize = DefaultMaxSize; | 335 | long maxSize = DefaultMaxSize; |
336 | int maxCount = DefaultMaxCount; | 336 | int maxCount = DefaultMaxCount; |
diff --git a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs index 9216e0b..967c0a1 100644 --- a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs +++ b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs | |||
@@ -69,7 +69,7 @@ namespace Flotsam.RegionModules.AssetCache | |||
69 | 69 | ||
70 | private readonly List<char> m_InvalidChars = new List<char>(); | 70 | private readonly List<char> m_InvalidChars = new List<char>(); |
71 | 71 | ||
72 | private int m_LogLevel = 1; | 72 | private int m_LogLevel = 0; |
73 | private ulong m_HitRateDisplay = 1; // How often to display hit statistics, given in requests | 73 | private ulong m_HitRateDisplay = 1; // How often to display hit statistics, given in requests |
74 | 74 | ||
75 | private static ulong m_Requests; | 75 | private static ulong m_Requests; |
@@ -156,7 +156,7 @@ namespace Flotsam.RegionModules.AssetCache | |||
156 | m_WaitOnInprogressTimeout = assetConfig.GetInt("WaitOnInprogressTimeout", 3000); | 156 | m_WaitOnInprogressTimeout = assetConfig.GetInt("WaitOnInprogressTimeout", 3000); |
157 | #endif | 157 | #endif |
158 | 158 | ||
159 | m_LogLevel = assetConfig.GetInt("LogLevel", 1); | 159 | m_LogLevel = assetConfig.GetInt("LogLevel", 0); |
160 | m_HitRateDisplay = (ulong)assetConfig.GetInt("HitRateDisplay", 1000); | 160 | m_HitRateDisplay = (ulong)assetConfig.GetInt("HitRateDisplay", 1000); |
161 | 161 | ||
162 | m_FileExpiration = TimeSpan.FromHours(assetConfig.GetDouble("FileCacheTimeout", m_DefaultFileExpiration)); | 162 | m_FileExpiration = TimeSpan.FromHours(assetConfig.GetDouble("FileCacheTimeout", m_DefaultFileExpiration)); |
diff --git a/OpenSim/Region/CoreModules/Avatar/Combat/CombatModule.cs b/OpenSim/Region/CoreModules/Avatar/Combat/CombatModule.cs index 0bd68dd..3614915 100644 --- a/OpenSim/Region/CoreModules/Avatar/Combat/CombatModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Combat/CombatModule.cs | |||
@@ -159,7 +159,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Combat.CombatModule | |||
159 | avatar.Invulnerable = true; | 159 | avatar.Invulnerable = true; |
160 | } | 160 | } |
161 | } | 161 | } |
162 | catch (Exception ex) | 162 | catch (Exception) |
163 | { | 163 | { |
164 | } | 164 | } |
165 | } | 165 | } |
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs index b055f8b..71b3062 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs | |||
@@ -131,7 +131,20 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
131 | { | 131 | { |
132 | if (CheckPresence(userInfo.PrincipalID)) | 132 | if (CheckPresence(userInfo.PrincipalID)) |
133 | { | 133 | { |
134 | new InventoryArchiveWriteRequest(id, this, m_aScene, userInfo, invPath, saveStream).Execute(); | 134 | try |
135 | { | ||
136 | new InventoryArchiveWriteRequest(id, this, m_aScene, userInfo, invPath, saveStream).Execute(); | ||
137 | } | ||
138 | catch (EntryPointNotFoundException e) | ||
139 | { | ||
140 | m_log.ErrorFormat( | ||
141 | "[ARCHIVER]: Mismatch between Mono and zlib1g library version when trying to create compression stream." | ||
142 | + "If you've manually installed Mono, have you appropriately updated zlib1g as well?"); | ||
143 | m_log.Error(e); | ||
144 | |||
145 | return false; | ||
146 | } | ||
147 | |||
135 | return true; | 148 | return true; |
136 | } | 149 | } |
137 | else | 150 | else |
@@ -156,7 +169,20 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
156 | { | 169 | { |
157 | if (CheckPresence(userInfo.PrincipalID)) | 170 | if (CheckPresence(userInfo.PrincipalID)) |
158 | { | 171 | { |
159 | new InventoryArchiveWriteRequest(id, this, m_aScene, userInfo, invPath, savePath).Execute(); | 172 | try |
173 | { | ||
174 | new InventoryArchiveWriteRequest(id, this, m_aScene, userInfo, invPath, savePath).Execute(); | ||
175 | } | ||
176 | catch (EntryPointNotFoundException e) | ||
177 | { | ||
178 | m_log.ErrorFormat( | ||
179 | "[ARCHIVER]: Mismatch between Mono and zlib1g library version when trying to create compression stream." | ||
180 | + "If you've manually installed Mono, have you appropriately updated zlib1g as well?"); | ||
181 | m_log.Error(e); | ||
182 | |||
183 | return false; | ||
184 | } | ||
185 | |||
160 | return true; | 186 | return true; |
161 | } | 187 | } |
162 | else | 188 | else |
@@ -181,8 +207,22 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
181 | { | 207 | { |
182 | if (CheckPresence(userInfo.PrincipalID)) | 208 | if (CheckPresence(userInfo.PrincipalID)) |
183 | { | 209 | { |
184 | InventoryArchiveReadRequest request = | 210 | InventoryArchiveReadRequest request; |
185 | new InventoryArchiveReadRequest(m_aScene, userInfo, invPath, loadStream); | 211 | |
212 | try | ||
213 | { | ||
214 | request = new InventoryArchiveReadRequest(m_aScene, userInfo, invPath, loadStream); | ||
215 | } | ||
216 | catch (EntryPointNotFoundException e) | ||
217 | { | ||
218 | m_log.ErrorFormat( | ||
219 | "[ARCHIVER]: Mismatch between Mono and zlib1g library version when trying to create compression stream." | ||
220 | + "If you've manually installed Mono, have you appropriately updated zlib1g as well?"); | ||
221 | m_log.Error(e); | ||
222 | |||
223 | return false; | ||
224 | } | ||
225 | |||
186 | UpdateClientWithLoadedNodes(userInfo, request.Execute()); | 226 | UpdateClientWithLoadedNodes(userInfo, request.Execute()); |
187 | 227 | ||
188 | return true; | 228 | return true; |
@@ -209,8 +249,22 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
209 | { | 249 | { |
210 | if (CheckPresence(userInfo.PrincipalID)) | 250 | if (CheckPresence(userInfo.PrincipalID)) |
211 | { | 251 | { |
212 | InventoryArchiveReadRequest request = | 252 | InventoryArchiveReadRequest request; |
213 | new InventoryArchiveReadRequest(m_aScene, userInfo, invPath, loadPath); | 253 | |
254 | try | ||
255 | { | ||
256 | request = new InventoryArchiveReadRequest(m_aScene, userInfo, invPath, loadPath); | ||
257 | } | ||
258 | catch (EntryPointNotFoundException e) | ||
259 | { | ||
260 | m_log.ErrorFormat( | ||
261 | "[ARCHIVER]: Mismatch between Mono and zlib1g library version when trying to create compression stream." | ||
262 | + "If you've manually installed Mono, have you appropriately updated zlib1g as well?"); | ||
263 | m_log.Error(e); | ||
264 | |||
265 | return false; | ||
266 | } | ||
267 | |||
214 | UpdateClientWithLoadedNodes(userInfo, request.Execute()); | 268 | UpdateClientWithLoadedNodes(userInfo, request.Execute()); |
215 | 269 | ||
216 | return true; | 270 | return true; |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/LocalAssetServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/LocalAssetServiceConnector.cs index 2f21e6d..50348da 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/LocalAssetServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/LocalAssetServiceConnector.cs | |||
@@ -224,7 +224,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset | |||
224 | m_Cache.Cache(a); | 224 | m_Cache.Cache(a); |
225 | 225 | ||
226 | // if (null == a) | 226 | // if (null == a) |
227 | // m_log.WarnFormat("[LOCAL ASSET SERVICES CONNECTOR]: Could not asynchronously find asset with id {0}", id); | 227 | // m_log.WarnFormat("[LOCAL ASSET SERVICES CONNECTOR]: Could not asynchronously find asset with id {0}", id); |
228 | 228 | ||
229 | Util.FireAndForget(delegate { handler(assetID, s, a); }); | 229 | Util.FireAndForget(delegate { handler(assetID, s, a); }); |
230 | }); | 230 | }); |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs index 2ca90f8..95d8737 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs | |||
@@ -56,7 +56,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.Tests | |||
56 | config.AddConfig("GridService"); | 56 | config.AddConfig("GridService"); |
57 | config.Configs["Modules"].Set("GridServices", "LocalGridServicesConnector"); | 57 | config.Configs["Modules"].Set("GridServices", "LocalGridServicesConnector"); |
58 | config.Configs["GridService"].Set("LocalServiceModule", "OpenSim.Services.GridService.dll:GridService"); | 58 | config.Configs["GridService"].Set("LocalServiceModule", "OpenSim.Services.GridService.dll:GridService"); |
59 | config.Configs["GridService"].Set("StorageProvider", "OpenSim.Data.Null.dll:NullRegionData"); | 59 | config.Configs["GridService"].Set("StorageProvider", "OpenSim.Data.Null.dll"); |
60 | 60 | ||
61 | m_LocalConnector = new LocalGridServicesConnector(config); | 61 | m_LocalConnector = new LocalGridServicesConnector(config); |
62 | } | 62 | } |
@@ -92,7 +92,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.Tests | |||
92 | r2.HttpPort = 9002; | 92 | r2.HttpPort = 9002; |
93 | r2.InternalEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("0.0.0.0"), 0); | 93 | r2.InternalEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("0.0.0.0"), 0); |
94 | s = new Scene(new RegionInfo()); | 94 | s = new Scene(new RegionInfo()); |
95 | s.RegionInfo.RegionID = r1.RegionID; | 95 | s.RegionInfo.RegionID = r2.RegionID; |
96 | m_LocalConnector.AddRegion(s); | 96 | m_LocalConnector.AddRegion(s); |
97 | 97 | ||
98 | GridRegion r3 = new GridRegion(); | 98 | GridRegion r3 = new GridRegion(); |
@@ -104,7 +104,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.Tests | |||
104 | r3.HttpPort = 9003; | 104 | r3.HttpPort = 9003; |
105 | r3.InternalEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("0.0.0.0"), 0); | 105 | r3.InternalEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("0.0.0.0"), 0); |
106 | s = new Scene(new RegionInfo()); | 106 | s = new Scene(new RegionInfo()); |
107 | s.RegionInfo.RegionID = r1.RegionID; | 107 | s.RegionInfo.RegionID = r3.RegionID; |
108 | m_LocalConnector.AddRegion(s); | 108 | m_LocalConnector.AddRegion(s); |
109 | 109 | ||
110 | m_LocalConnector.RegisterRegion(UUID.Zero, r1); | 110 | m_LocalConnector.RegisterRegion(UUID.Zero, r1); |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs index 54e62e2..e97d21f 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs | |||
@@ -314,7 +314,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory | |||
314 | item = m_InventoryService.GetItem(item); | 314 | item = m_InventoryService.GetItem(item); |
315 | 315 | ||
316 | if (null == item) | 316 | if (null == item) |
317 | m_log.ErrorFormat("[LOCAL INVENTORY SERVICES CONNECTOR]: Could not find item with id {0}"); | 317 | m_log.ErrorFormat("[LOCAL INVENTORY SERVICES CONNECTOR]: Could not find item with id {0}", item.ID); |
318 | 318 | ||
319 | return item; | 319 | return item; |
320 | } | 320 | } |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/Tests/PresenceConnectorsTests.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/Tests/PresenceConnectorsTests.cs index 9ba1bdc..ca42461 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/Tests/PresenceConnectorsTests.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/Tests/PresenceConnectorsTests.cs | |||
@@ -56,7 +56,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence.Tests | |||
56 | config.AddConfig("PresenceService"); | 56 | config.AddConfig("PresenceService"); |
57 | config.Configs["Modules"].Set("PresenceServices", "LocalPresenceServicesConnector"); | 57 | config.Configs["Modules"].Set("PresenceServices", "LocalPresenceServicesConnector"); |
58 | config.Configs["PresenceService"].Set("LocalServiceModule", "OpenSim.Services.PresenceService.dll:PresenceService"); | 58 | config.Configs["PresenceService"].Set("LocalServiceModule", "OpenSim.Services.PresenceService.dll:PresenceService"); |
59 | config.Configs["PresenceService"].Set("StorageProvider", "OpenSim.Data.Null.dll:NullPresenceData"); | 59 | config.Configs["PresenceService"].Set("StorageProvider", "OpenSim.Data.Null.dll"); |
60 | 60 | ||
61 | m_LocalConnector = new LocalPresenceServicesConnector(config); | 61 | m_LocalConnector = new LocalPresenceServicesConnector(config); |
62 | } | 62 | } |
diff --git a/OpenSim/Region/CoreModules/World/Access/AccessModule.cs b/OpenSim/Region/CoreModules/World/Access/AccessModule.cs index 127469e..c355b13 100644 --- a/OpenSim/Region/CoreModules/World/Access/AccessModule.cs +++ b/OpenSim/Region/CoreModules/World/Access/AccessModule.cs | |||
@@ -108,7 +108,7 @@ namespace OpenSim.Region.CoreModules.World | |||
108 | { | 108 | { |
109 | foreach (Scene s in m_SceneList) | 109 | foreach (Scene s in m_SceneList) |
110 | { | 110 | { |
111 | if(!ProcessCommand(s, cmd)) | 111 | if (!ProcessCommand(s, cmd)) |
112 | break; | 112 | break; |
113 | } | 113 | } |
114 | } | 114 | } |
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs index c4b1817..f5eda3a 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs | |||
@@ -74,7 +74,19 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
74 | public ArchiveReadRequest(Scene scene, string loadPath, bool merge, Guid requestId) | 74 | public ArchiveReadRequest(Scene scene, string loadPath, bool merge, Guid requestId) |
75 | { | 75 | { |
76 | m_scene = scene; | 76 | m_scene = scene; |
77 | m_loadStream = new GZipStream(GetStream(loadPath), CompressionMode.Decompress); | 77 | |
78 | try | ||
79 | { | ||
80 | m_loadStream = new GZipStream(GetStream(loadPath), CompressionMode.Decompress); | ||
81 | } | ||
82 | catch (EntryPointNotFoundException e) | ||
83 | { | ||
84 | m_log.ErrorFormat( | ||
85 | "[ARCHIVER]: Mismatch between Mono and zlib1g library version when trying to create compression stream." | ||
86 | + "If you've manually installed Mono, have you appropriately updated zlib1g as well?"); | ||
87 | m_log.Error(e); | ||
88 | } | ||
89 | |||
78 | m_errorMessage = String.Empty; | 90 | m_errorMessage = String.Empty; |
79 | m_merge = merge; | 91 | m_merge = merge; |
80 | m_requestId = requestId; | 92 | m_requestId = requestId; |
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs index 71bfe57..b61b341 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs | |||
@@ -65,7 +65,19 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
65 | public ArchiveWriteRequestPreparation(Scene scene, string savePath, Guid requestId) | 65 | public ArchiveWriteRequestPreparation(Scene scene, string savePath, Guid requestId) |
66 | { | 66 | { |
67 | m_scene = scene; | 67 | m_scene = scene; |
68 | m_saveStream = new GZipStream(new FileStream(savePath, FileMode.Create), CompressionMode.Compress); | 68 | |
69 | try | ||
70 | { | ||
71 | m_saveStream = new GZipStream(new FileStream(savePath, FileMode.Create), CompressionMode.Compress); | ||
72 | } | ||
73 | catch (EntryPointNotFoundException e) | ||
74 | { | ||
75 | m_log.ErrorFormat( | ||
76 | "[ARCHIVER]: Mismatch between Mono and zlib1g library version when trying to create compression stream." | ||
77 | + "If you've manually installed Mono, have you appropriately updated zlib1g as well?"); | ||
78 | m_log.Error(e); | ||
79 | } | ||
80 | |||
69 | m_requestId = requestId; | 81 | m_requestId = requestId; |
70 | } | 82 | } |
71 | 83 | ||
diff --git a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs index d986274..de16d89 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs | |||
@@ -63,7 +63,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests | |||
63 | SerialiserModule serialiserModule = new SerialiserModule(); | 63 | SerialiserModule serialiserModule = new SerialiserModule(); |
64 | TerrainModule terrainModule = new TerrainModule(); | 64 | TerrainModule terrainModule = new TerrainModule(); |
65 | 65 | ||
66 | m_scene = SceneSetupHelpers.SetupScene("scene1"); | 66 | m_scene = SceneSetupHelpers.SetupScene("useraccounts"); |
67 | SceneSetupHelpers.SetupSceneModules(m_scene, m_archiverModule, serialiserModule, terrainModule); | 67 | SceneSetupHelpers.SetupSceneModules(m_scene, m_archiverModule, serialiserModule, terrainModule); |
68 | } | 68 | } |
69 | 69 | ||
@@ -99,7 +99,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests | |||
99 | Quaternion rotationOffset = new Quaternion(20, 30, 40, 50); | 99 | Quaternion rotationOffset = new Quaternion(20, 30, 40, 50); |
100 | Vector3 offsetPosition = new Vector3(5, 10, 15); | 100 | Vector3 offsetPosition = new Vector3(5, 10, 15); |
101 | 101 | ||
102 | return new SceneObjectPart(ownerId, shape, groupPosition, rotationOffset, offsetPosition) { Name = partName }; | 102 | return new SceneObjectPart(ownerId, shape, groupPosition, rotationOffset, offsetPosition) { Name = partName }; |
103 | } | 103 | } |
104 | 104 | ||
105 | protected SceneObjectPart CreateSceneObjectPart2() | 105 | protected SceneObjectPart CreateSceneObjectPart2() |
@@ -112,7 +112,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests | |||
112 | Vector3 offsetPosition = new Vector3(20, 25, 30); | 112 | Vector3 offsetPosition = new Vector3(20, 25, 30); |
113 | 113 | ||
114 | return new SceneObjectPart(ownerId, shape, groupPosition, rotationOffset, offsetPosition) { Name = partName }; | 114 | return new SceneObjectPart(ownerId, shape, groupPosition, rotationOffset, offsetPosition) { Name = partName }; |
115 | } | 115 | } |
116 | 116 | ||
117 | /// <summary> | 117 | /// <summary> |
118 | /// Test saving a V0.2 OpenSim Region Archive. | 118 | /// Test saving a V0.2 OpenSim Region Archive. |
@@ -231,7 +231,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests | |||
231 | foreach (string name in names) | 231 | foreach (string name in names) |
232 | { | 232 | { |
233 | if (name.EndsWith(".Resources.test-sound.wav")) | 233 | if (name.EndsWith(".Resources.test-sound.wav")) |
234 | soundDataResourceName = name; | 234 | soundDataResourceName = name; |
235 | } | 235 | } |
236 | Assert.That(soundDataResourceName, Is.Not.Null); | 236 | Assert.That(soundDataResourceName, Is.Not.Null); |
237 | 237 | ||
@@ -259,7 +259,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests | |||
259 | = new TaskInventoryItem { AssetID = soundUuid, ItemID = soundItemUuid, Name = soundItemName }; | 259 | = new TaskInventoryItem { AssetID = soundUuid, ItemID = soundItemUuid, Name = soundItemName }; |
260 | part1.Inventory.AddInventoryItem(item1, true); | 260 | part1.Inventory.AddInventoryItem(item1, true); |
261 | } | 261 | } |
262 | } | 262 | } |
263 | 263 | ||
264 | m_scene.AddNewSceneObject(object1, false); | 264 | m_scene.AddNewSceneObject(object1, false); |
265 | 265 | ||
@@ -306,15 +306,15 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests | |||
306 | /// Test loading the region settings of a V0.2 OpenSim Region Archive. | 306 | /// Test loading the region settings of a V0.2 OpenSim Region Archive. |
307 | /// </summary> | 307 | /// </summary> |
308 | [Test] | 308 | [Test] |
309 | public void TestLoadOarV0_2RegionSettings() | 309 | public void TestLoadOarV0_2RegionSettings() |
310 | { | 310 | { |
311 | TestHelper.InMethod(); | 311 | TestHelper.InMethod(); |
312 | //log4net.Config.XmlConfigurator.Configure(); | 312 | //log4net.Config.XmlConfigurator.Configure(); |
313 | 313 | ||
314 | MemoryStream archiveWriteStream = new MemoryStream(); | 314 | MemoryStream archiveWriteStream = new MemoryStream(); |
315 | TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream); | 315 | TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream); |
316 | 316 | ||
317 | tar.WriteDir(ArchiveConstants.TERRAINS_PATH); | 317 | tar.WriteDir(ArchiveConstants.TERRAINS_PATH); |
318 | tar.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, ArchiveWriteRequestExecution.Create0p2ControlFile()); | 318 | tar.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, ArchiveWriteRequestExecution.Create0p2ControlFile()); |
319 | 319 | ||
320 | RegionSettings rs = new RegionSettings(); | 320 | RegionSettings rs = new RegionSettings(); |
@@ -329,11 +329,11 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests | |||
329 | rs.DisablePhysics = true; | 329 | rs.DisablePhysics = true; |
330 | rs.DisableScripts = true; | 330 | rs.DisableScripts = true; |
331 | rs.Elevation1NW = 15.9; | 331 | rs.Elevation1NW = 15.9; |
332 | rs.Elevation1NE = 45.3; | 332 | rs.Elevation1NE = 45.3; |
333 | rs.Elevation1SE = 49; | 333 | rs.Elevation1SE = 49; |
334 | rs.Elevation1SW = 1.9; | 334 | rs.Elevation1SW = 1.9; |
335 | rs.Elevation2NW = 4.5; | 335 | rs.Elevation2NW = 4.5; |
336 | rs.Elevation2NE = 19.2; | 336 | rs.Elevation2NE = 19.2; |
337 | rs.Elevation2SE = 9.2; | 337 | rs.Elevation2SE = 9.2; |
338 | rs.Elevation2SW = 2.1; | 338 | rs.Elevation2SW = 2.1; |
339 | rs.FixedSun = true; | 339 | rs.FixedSun = true; |
@@ -411,7 +411,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests | |||
411 | // Quaternion part2RotationOffset = new Quaternion(60, 70, 80, 90); | 411 | // Quaternion part2RotationOffset = new Quaternion(60, 70, 80, 90); |
412 | // Vector3 part2OffsetPosition = new Vector3(20, 25, 30); | 412 | // Vector3 part2OffsetPosition = new Vector3(20, 25, 30); |
413 | 413 | ||
414 | SceneObjectPart part2 = CreateSceneObjectPart2(); | 414 | SceneObjectPart part2 = CreateSceneObjectPart2(); |
415 | 415 | ||
416 | // Create an oar file that we can use for the merge | 416 | // Create an oar file that we can use for the merge |
417 | { | 417 | { |
@@ -420,9 +420,9 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests | |||
420 | TerrainModule terrainModule = new TerrainModule(); | 420 | TerrainModule terrainModule = new TerrainModule(); |
421 | 421 | ||
422 | Scene scene = SceneSetupHelpers.SetupScene(); | 422 | Scene scene = SceneSetupHelpers.SetupScene(); |
423 | SceneSetupHelpers.SetupSceneModules(scene, archiverModule, serialiserModule, terrainModule); | 423 | SceneSetupHelpers.SetupSceneModules(scene, archiverModule, serialiserModule, terrainModule); |
424 | 424 | ||
425 | m_scene.AddNewSceneObject(new SceneObjectGroup(part2), false); | 425 | m_scene.AddNewSceneObject(new SceneObjectGroup(part2), false); |
426 | 426 | ||
427 | // Write out this scene | 427 | // Write out this scene |
428 | scene.EventManager.OnOarFileSaved += SaveCompleted; | 428 | scene.EventManager.OnOarFileSaved += SaveCompleted; |
diff --git a/OpenSim/Region/Framework/Interfaces/IDynamicTextureManager.cs b/OpenSim/Region/Framework/Interfaces/IDynamicTextureManager.cs index c289cdb..8954513 100644 --- a/OpenSim/Region/Framework/Interfaces/IDynamicTextureManager.cs +++ b/OpenSim/Region/Framework/Interfaces/IDynamicTextureManager.cs | |||
@@ -65,7 +65,7 @@ namespace OpenSim.Region.Framework.Interfaces | |||
65 | /// The UUID of the texture updater, not the texture UUID. If you need the texture UUID then you will need | 65 | /// The UUID of the texture updater, not the texture UUID. If you need the texture UUID then you will need |
66 | /// to obtain it directly from the SceneObjectPart. For instance, if ALL_SIDES is set then this texture | 66 | /// to obtain it directly from the SceneObjectPart. For instance, if ALL_SIDES is set then this texture |
67 | /// can be obtained as SceneObjectPart.Shape.Textures.DefaultTexture.TextureID | 67 | /// can be obtained as SceneObjectPart.Shape.Textures.DefaultTexture.TextureID |
68 | /// </returns> | 68 | /// </returns> |
69 | UUID AddDynamicTextureData(UUID simID, UUID primID, string contentType, string data, string extraParams, | 69 | UUID AddDynamicTextureData(UUID simID, UUID primID, string contentType, string data, string extraParams, |
70 | int updateTimer, bool SetBlending, byte AlphaValue); | 70 | int updateTimer, bool SetBlending, byte AlphaValue); |
71 | 71 | ||
diff --git a/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs b/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs index fa9bf19..f58904f 100644 --- a/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs +++ b/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs | |||
@@ -150,7 +150,7 @@ namespace OpenSim.Region.Framework.Interfaces | |||
150 | /// <returns> | 150 | /// <returns> |
151 | /// A list of inventory items with that name. | 151 | /// A list of inventory items with that name. |
152 | /// If no inventory item has that name then an empty list is returned. | 152 | /// If no inventory item has that name then an empty list is returned. |
153 | /// </returns> | 153 | /// </returns> |
154 | IList<TaskInventoryItem> GetInventoryItems(string name); | 154 | IList<TaskInventoryItem> GetInventoryItems(string name); |
155 | 155 | ||
156 | /// <summary> | 156 | /// <summary> |
diff --git a/OpenSim/Region/Framework/Interfaces/IWorldComm.cs b/OpenSim/Region/Framework/Interfaces/IWorldComm.cs index 948b9dc..8da99a0 100644 --- a/OpenSim/Region/Framework/Interfaces/IWorldComm.cs +++ b/OpenSim/Region/Framework/Interfaces/IWorldComm.cs | |||
@@ -62,7 +62,7 @@ namespace OpenSim.Region.Framework.Interfaces | |||
62 | /// <param name="name">name to filter on</param> | 62 | /// <param name="name">name to filter on</param> |
63 | /// <param name="id">key to filter on (user given, could be totally faked)</param> | 63 | /// <param name="id">key to filter on (user given, could be totally faked)</param> |
64 | /// <param name="msg">msg to filter on</param> | 64 | /// <param name="msg">msg to filter on</param> |
65 | /// <returns>number of the scripts handle</returns> | 65 | /// <returns>number of the scripts handle</returns> |
66 | int Listen(uint LocalID, UUID itemID, UUID hostID, int channel, string name, UUID id, string msg); | 66 | int Listen(uint LocalID, UUID itemID, UUID hostID, int channel, string name, UUID id, string msg); |
67 | 67 | ||
68 | /// <summary> | 68 | /// <summary> |
@@ -77,19 +77,19 @@ namespace OpenSim.Region.Framework.Interfaces | |||
77 | /// <param name="channel">channel to sent on</param> | 77 | /// <param name="channel">channel to sent on</param> |
78 | /// <param name="name">name of sender (object or avatar)</param> | 78 | /// <param name="name">name of sender (object or avatar)</param> |
79 | /// <param name="id">key of sender (object or avatar)</param> | 79 | /// <param name="id">key of sender (object or avatar)</param> |
80 | /// <param name="msg">msg to sent</param> | 80 | /// <param name="msg">msg to sent</param> |
81 | void DeliverMessage(ChatTypeEnum type, int channel, string name, UUID id, string msg); | 81 | void DeliverMessage(ChatTypeEnum type, int channel, string name, UUID id, string msg); |
82 | 82 | ||
83 | /// <summary> | 83 | /// <summary> |
84 | /// Are there any listen events ready to be dispatched? | 84 | /// Are there any listen events ready to be dispatched? |
85 | /// </summary> | 85 | /// </summary> |
86 | /// <returns>boolean indication</returns> | 86 | /// <returns>boolean indication</returns> |
87 | bool HasMessages(); | 87 | bool HasMessages(); |
88 | 88 | ||
89 | /// <summary> | 89 | /// <summary> |
90 | /// Pop the first availlable listen event from the queue | 90 | /// Pop the first availlable listen event from the queue |
91 | /// </summary> | 91 | /// </summary> |
92 | /// <returns>ListenerInfo with filter filled in</returns> | 92 | /// <returns>ListenerInfo with filter filled in</returns> |
93 | IWorldCommListenerInfo GetNextMessage(); | 93 | IWorldCommListenerInfo GetNextMessage(); |
94 | 94 | ||
95 | void ListenControl(UUID itemID, int handle, int active); | 95 | void ListenControl(UUID itemID, int handle, int active); |
diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs index 9f74b2a..57e1c37 100644 --- a/OpenSim/Region/Framework/Scenes/EventManager.cs +++ b/OpenSim/Region/Framework/Scenes/EventManager.cs | |||
@@ -209,7 +209,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
209 | /// Triggered when an object or attachment enters a scene | 209 | /// Triggered when an object or attachment enters a scene |
210 | /// </summary> | 210 | /// </summary> |
211 | public event OnIncomingSceneObjectDelegate OnIncomingSceneObject; | 211 | public event OnIncomingSceneObjectDelegate OnIncomingSceneObject; |
212 | public delegate void OnIncomingSceneObjectDelegate(SceneObjectGroup so); | 212 | public delegate void OnIncomingSceneObjectDelegate(SceneObjectGroup so); |
213 | 213 | ||
214 | public delegate void NewInventoryItemUploadComplete(UUID avatarID, UUID assetID, string name, int userlevel); | 214 | public delegate void NewInventoryItemUploadComplete(UUID avatarID, UUID assetID, string name, int userlevel); |
215 | 215 | ||
@@ -413,7 +413,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
413 | } | 413 | } |
414 | } | 414 | } |
415 | } | 415 | } |
416 | } | 416 | } |
417 | 417 | ||
418 | public void TriggerGetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID) | 418 | public void TriggerGetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID) |
419 | { | 419 | { |
@@ -433,7 +433,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
433 | e.Message, e.StackTrace); | 433 | e.Message, e.StackTrace); |
434 | } | 434 | } |
435 | } | 435 | } |
436 | } | 436 | } |
437 | } | 437 | } |
438 | 438 | ||
439 | public void TriggerOnScriptChangedEvent(uint localID, uint change) | 439 | public void TriggerOnScriptChangedEvent(uint localID, uint change) |
@@ -454,7 +454,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
454 | e.Message, e.StackTrace); | 454 | e.Message, e.StackTrace); |
455 | } | 455 | } |
456 | } | 456 | } |
457 | } | 457 | } |
458 | } | 458 | } |
459 | 459 | ||
460 | public void TriggerOnClientMovement(ScenePresence avatar) | 460 | public void TriggerOnClientMovement(ScenePresence avatar) |
@@ -475,7 +475,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
475 | e.Message, e.StackTrace); | 475 | e.Message, e.StackTrace); |
476 | } | 476 | } |
477 | } | 477 | } |
478 | } | 478 | } |
479 | } | 479 | } |
480 | 480 | ||
481 | public void TriggerPermissionError(UUID user, string reason) | 481 | public void TriggerPermissionError(UUID user, string reason) |
@@ -496,7 +496,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
496 | e.Message, e.StackTrace); | 496 | e.Message, e.StackTrace); |
497 | } | 497 | } |
498 | } | 498 | } |
499 | } | 499 | } |
500 | } | 500 | } |
501 | 501 | ||
502 | public void TriggerOnPluginConsole(string[] args) | 502 | public void TriggerOnPluginConsole(string[] args) |
@@ -517,7 +517,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
517 | e.Message, e.StackTrace); | 517 | e.Message, e.StackTrace); |
518 | } | 518 | } |
519 | } | 519 | } |
520 | } | 520 | } |
521 | } | 521 | } |
522 | 522 | ||
523 | public void TriggerOnFrame() | 523 | public void TriggerOnFrame() |
@@ -538,11 +538,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
538 | e.Message, e.StackTrace); | 538 | e.Message, e.StackTrace); |
539 | } | 539 | } |
540 | } | 540 | } |
541 | } | 541 | } |
542 | } | 542 | } |
543 | 543 | ||
544 | public void TriggerOnNewClient(IClientAPI client) | 544 | public void TriggerOnNewClient(IClientAPI client) |
545 | { | 545 | { |
546 | OnNewClientDelegate handlerNewClient = OnNewClient; | 546 | OnNewClientDelegate handlerNewClient = OnNewClient; |
547 | if (handlerNewClient != null) | 547 | if (handlerNewClient != null) |
548 | { | 548 | { |
@@ -559,10 +559,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
559 | e.Message, e.StackTrace); | 559 | e.Message, e.StackTrace); |
560 | } | 560 | } |
561 | } | 561 | } |
562 | } | 562 | } |
563 | 563 | ||
564 | if (client is IClientCore) | 564 | if (client is IClientCore) |
565 | { | 565 | { |
566 | OnClientConnectCoreDelegate handlerClientConnect = OnClientConnect; | 566 | OnClientConnectCoreDelegate handlerClientConnect = OnClientConnect; |
567 | if (handlerClientConnect != null) | 567 | if (handlerClientConnect != null) |
568 | { | 568 | { |
@@ -579,7 +579,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
579 | e.Message, e.StackTrace); | 579 | e.Message, e.StackTrace); |
580 | } | 580 | } |
581 | } | 581 | } |
582 | } | 582 | } |
583 | } | 583 | } |
584 | } | 584 | } |
585 | 585 | ||
@@ -601,11 +601,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
601 | e.Message, e.StackTrace); | 601 | e.Message, e.StackTrace); |
602 | } | 602 | } |
603 | } | 603 | } |
604 | } | 604 | } |
605 | } | 605 | } |
606 | 606 | ||
607 | public void TriggerOnRemovePresence(UUID agentId) | 607 | public void TriggerOnRemovePresence(UUID agentId) |
608 | { | 608 | { |
609 | OnRemovePresenceDelegate handlerRemovePresence = OnRemovePresence; | 609 | OnRemovePresenceDelegate handlerRemovePresence = OnRemovePresence; |
610 | if (handlerRemovePresence != null) | 610 | if (handlerRemovePresence != null) |
611 | { | 611 | { |
@@ -622,11 +622,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
622 | e.Message, e.StackTrace); | 622 | e.Message, e.StackTrace); |
623 | } | 623 | } |
624 | } | 624 | } |
625 | } | 625 | } |
626 | } | 626 | } |
627 | 627 | ||
628 | public void TriggerOnBackup(IRegionDataStore dstore) | 628 | public void TriggerOnBackup(IRegionDataStore dstore) |
629 | { | 629 | { |
630 | OnBackupDelegate handlerOnAttach = OnBackup; | 630 | OnBackupDelegate handlerOnAttach = OnBackup; |
631 | if (handlerOnAttach != null) | 631 | if (handlerOnAttach != null) |
632 | { | 632 | { |
@@ -643,7 +643,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
643 | e.Message, e.StackTrace); | 643 | e.Message, e.StackTrace); |
644 | } | 644 | } |
645 | } | 645 | } |
646 | } | 646 | } |
647 | } | 647 | } |
648 | 648 | ||
649 | public void TriggerParcelPrimCountUpdate() | 649 | public void TriggerParcelPrimCountUpdate() |
@@ -664,7 +664,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
664 | e.Message, e.StackTrace); | 664 | e.Message, e.StackTrace); |
665 | } | 665 | } |
666 | } | 666 | } |
667 | } | 667 | } |
668 | } | 668 | } |
669 | 669 | ||
670 | public void TriggerMoneyTransfer(Object sender, MoneyTransferArgs args) | 670 | public void TriggerMoneyTransfer(Object sender, MoneyTransferArgs args) |
@@ -685,7 +685,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
685 | e.Message, e.StackTrace); | 685 | e.Message, e.StackTrace); |
686 | } | 686 | } |
687 | } | 687 | } |
688 | } | 688 | } |
689 | } | 689 | } |
690 | 690 | ||
691 | public void TriggerTerrainTick() | 691 | public void TriggerTerrainTick() |
@@ -706,7 +706,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
706 | e.Message, e.StackTrace); | 706 | e.Message, e.StackTrace); |
707 | } | 707 | } |
708 | } | 708 | } |
709 | } | 709 | } |
710 | } | 710 | } |
711 | 711 | ||
712 | public void TriggerParcelPrimCountAdd(SceneObjectGroup obj) | 712 | public void TriggerParcelPrimCountAdd(SceneObjectGroup obj) |
@@ -727,7 +727,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
727 | e.Message, e.StackTrace); | 727 | e.Message, e.StackTrace); |
728 | } | 728 | } |
729 | } | 729 | } |
730 | } | 730 | } |
731 | } | 731 | } |
732 | 732 | ||
733 | public void TriggerObjectBeingRemovedFromScene(SceneObjectGroup obj) | 733 | public void TriggerObjectBeingRemovedFromScene(SceneObjectGroup obj) |
@@ -748,11 +748,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
748 | e.Message, e.StackTrace); | 748 | e.Message, e.StackTrace); |
749 | } | 749 | } |
750 | } | 750 | } |
751 | } | 751 | } |
752 | } | 752 | } |
753 | 753 | ||
754 | public void TriggerShutdown() | 754 | public void TriggerShutdown() |
755 | { | 755 | { |
756 | OnShutdownDelegate handlerShutdown = OnShutdown; | 756 | OnShutdownDelegate handlerShutdown = OnShutdown; |
757 | if (handlerShutdown != null) | 757 | if (handlerShutdown != null) |
758 | { | 758 | { |
@@ -769,11 +769,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
769 | e.Message, e.StackTrace); | 769 | e.Message, e.StackTrace); |
770 | } | 770 | } |
771 | } | 771 | } |
772 | } | 772 | } |
773 | } | 773 | } |
774 | 774 | ||
775 | public void TriggerObjectGrab(uint localID, uint originalID, Vector3 offsetPos, IClientAPI remoteClient, SurfaceTouchEventArgs surfaceArgs) | 775 | public void TriggerObjectGrab(uint localID, uint originalID, Vector3 offsetPos, IClientAPI remoteClient, SurfaceTouchEventArgs surfaceArgs) |
776 | { | 776 | { |
777 | ObjectGrabDelegate handlerObjectGrab = OnObjectGrab; | 777 | ObjectGrabDelegate handlerObjectGrab = OnObjectGrab; |
778 | if (handlerObjectGrab != null) | 778 | if (handlerObjectGrab != null) |
779 | { | 779 | { |
@@ -790,11 +790,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
790 | e.Message, e.StackTrace); | 790 | e.Message, e.StackTrace); |
791 | } | 791 | } |
792 | } | 792 | } |
793 | } | 793 | } |
794 | } | 794 | } |
795 | 795 | ||
796 | public void TriggerObjectGrabbing(uint localID, uint originalID, Vector3 offsetPos, IClientAPI remoteClient, SurfaceTouchEventArgs surfaceArgs) | 796 | public void TriggerObjectGrabbing(uint localID, uint originalID, Vector3 offsetPos, IClientAPI remoteClient, SurfaceTouchEventArgs surfaceArgs) |
797 | { | 797 | { |
798 | ObjectGrabDelegate handlerObjectGrabbing = OnObjectGrabbing; | 798 | ObjectGrabDelegate handlerObjectGrabbing = OnObjectGrabbing; |
799 | if (handlerObjectGrabbing != null) | 799 | if (handlerObjectGrabbing != null) |
800 | { | 800 | { |
@@ -811,11 +811,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
811 | e.Message, e.StackTrace); | 811 | e.Message, e.StackTrace); |
812 | } | 812 | } |
813 | } | 813 | } |
814 | } | 814 | } |
815 | } | 815 | } |
816 | 816 | ||
817 | public void TriggerObjectDeGrab(uint localID, uint originalID, IClientAPI remoteClient, SurfaceTouchEventArgs surfaceArgs) | 817 | public void TriggerObjectDeGrab(uint localID, uint originalID, IClientAPI remoteClient, SurfaceTouchEventArgs surfaceArgs) |
818 | { | 818 | { |
819 | ObjectDeGrabDelegate handlerObjectDeGrab = OnObjectDeGrab; | 819 | ObjectDeGrabDelegate handlerObjectDeGrab = OnObjectDeGrab; |
820 | if (handlerObjectDeGrab != null) | 820 | if (handlerObjectDeGrab != null) |
821 | { | 821 | { |
@@ -832,11 +832,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
832 | e.Message, e.StackTrace); | 832 | e.Message, e.StackTrace); |
833 | } | 833 | } |
834 | } | 834 | } |
835 | } | 835 | } |
836 | } | 836 | } |
837 | 837 | ||
838 | public void TriggerScriptReset(uint localID, UUID itemID) | 838 | public void TriggerScriptReset(uint localID, UUID itemID) |
839 | { | 839 | { |
840 | ScriptResetDelegate handlerScriptReset = OnScriptReset; | 840 | ScriptResetDelegate handlerScriptReset = OnScriptReset; |
841 | if (handlerScriptReset != null) | 841 | if (handlerScriptReset != null) |
842 | { | 842 | { |
@@ -853,11 +853,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
853 | e.Message, e.StackTrace); | 853 | e.Message, e.StackTrace); |
854 | } | 854 | } |
855 | } | 855 | } |
856 | } | 856 | } |
857 | } | 857 | } |
858 | 858 | ||
859 | public void TriggerRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine, int stateSource) | 859 | public void TriggerRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine, int stateSource) |
860 | { | 860 | { |
861 | NewRezScript handlerRezScript = OnRezScript; | 861 | NewRezScript handlerRezScript = OnRezScript; |
862 | if (handlerRezScript != null) | 862 | if (handlerRezScript != null) |
863 | { | 863 | { |
@@ -874,7 +874,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
874 | e.Message, e.StackTrace); | 874 | e.Message, e.StackTrace); |
875 | } | 875 | } |
876 | } | 876 | } |
877 | } | 877 | } |
878 | } | 878 | } |
879 | 879 | ||
880 | public void TriggerStartScript(uint localID, UUID itemID) | 880 | public void TriggerStartScript(uint localID, UUID itemID) |
@@ -895,7 +895,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
895 | e.Message, e.StackTrace); | 895 | e.Message, e.StackTrace); |
896 | } | 896 | } |
897 | } | 897 | } |
898 | } | 898 | } |
899 | } | 899 | } |
900 | 900 | ||
901 | public void TriggerStopScript(uint localID, UUID itemID) | 901 | public void TriggerStopScript(uint localID, UUID itemID) |
@@ -916,11 +916,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
916 | e.Message, e.StackTrace); | 916 | e.Message, e.StackTrace); |
917 | } | 917 | } |
918 | } | 918 | } |
919 | } | 919 | } |
920 | } | 920 | } |
921 | 921 | ||
922 | public void TriggerRemoveScript(uint localID, UUID itemID) | 922 | public void TriggerRemoveScript(uint localID, UUID itemID) |
923 | { | 923 | { |
924 | RemoveScript handlerRemoveScript = OnRemoveScript; | 924 | RemoveScript handlerRemoveScript = OnRemoveScript; |
925 | if (handlerRemoveScript != null) | 925 | if (handlerRemoveScript != null) |
926 | { | 926 | { |
@@ -937,7 +937,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
937 | e.Message, e.StackTrace); | 937 | e.Message, e.StackTrace); |
938 | } | 938 | } |
939 | } | 939 | } |
940 | } | 940 | } |
941 | } | 941 | } |
942 | 942 | ||
943 | public bool TriggerGroupMove(UUID groupID, Vector3 delta) | 943 | public bool TriggerGroupMove(UUID groupID, Vector3 delta) |
@@ -1036,7 +1036,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1036 | e.Message, e.StackTrace); | 1036 | e.Message, e.StackTrace); |
1037 | } | 1037 | } |
1038 | } | 1038 | } |
1039 | } | 1039 | } |
1040 | } | 1040 | } |
1041 | 1041 | ||
1042 | public void TriggerLandObjectAdded(ILandObject newParcel) | 1042 | public void TriggerLandObjectAdded(ILandObject newParcel) |
@@ -1057,7 +1057,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1057 | e.Message, e.StackTrace); | 1057 | e.Message, e.StackTrace); |
1058 | } | 1058 | } |
1059 | } | 1059 | } |
1060 | } | 1060 | } |
1061 | } | 1061 | } |
1062 | 1062 | ||
1063 | public void TriggerLandObjectRemoved(UUID globalID) | 1063 | public void TriggerLandObjectRemoved(UUID globalID) |
@@ -1078,7 +1078,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1078 | e.Message, e.StackTrace); | 1078 | e.Message, e.StackTrace); |
1079 | } | 1079 | } |
1080 | } | 1080 | } |
1081 | } | 1081 | } |
1082 | } | 1082 | } |
1083 | 1083 | ||
1084 | public void TriggerLandObjectUpdated(uint localParcelID, ILandObject newParcel) | 1084 | public void TriggerLandObjectUpdated(uint localParcelID, ILandObject newParcel) |
@@ -1104,7 +1104,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1104 | e.Message, e.StackTrace); | 1104 | e.Message, e.StackTrace); |
1105 | } | 1105 | } |
1106 | } | 1106 | } |
1107 | } | 1107 | } |
1108 | } | 1108 | } |
1109 | 1109 | ||
1110 | public void TriggerIncomingInstantMessage(GridInstantMessage message) | 1110 | public void TriggerIncomingInstantMessage(GridInstantMessage message) |
@@ -1125,7 +1125,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1125 | e.Message, e.StackTrace); | 1125 | e.Message, e.StackTrace); |
1126 | } | 1126 | } |
1127 | } | 1127 | } |
1128 | } | 1128 | } |
1129 | } | 1129 | } |
1130 | 1130 | ||
1131 | public void TriggerUnhandledInstantMessage(GridInstantMessage message) | 1131 | public void TriggerUnhandledInstantMessage(GridInstantMessage message) |
@@ -1146,7 +1146,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1146 | e.Message, e.StackTrace); | 1146 | e.Message, e.StackTrace); |
1147 | } | 1147 | } |
1148 | } | 1148 | } |
1149 | } | 1149 | } |
1150 | } | 1150 | } |
1151 | 1151 | ||
1152 | public void TriggerClientClosed(UUID ClientID, Scene scene) | 1152 | public void TriggerClientClosed(UUID ClientID, Scene scene) |
@@ -1167,7 +1167,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1167 | e.Message, e.StackTrace); | 1167 | e.Message, e.StackTrace); |
1168 | } | 1168 | } |
1169 | } | 1169 | } |
1170 | } | 1170 | } |
1171 | } | 1171 | } |
1172 | 1172 | ||
1173 | public void TriggerOnMakeChildAgent(ScenePresence presence) | 1173 | public void TriggerOnMakeChildAgent(ScenePresence presence) |
@@ -1188,7 +1188,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1188 | e.Message, e.StackTrace); | 1188 | e.Message, e.StackTrace); |
1189 | } | 1189 | } |
1190 | } | 1190 | } |
1191 | } | 1191 | } |
1192 | } | 1192 | } |
1193 | 1193 | ||
1194 | public void TriggerOnMakeRootAgent(ScenePresence presence) | 1194 | public void TriggerOnMakeRootAgent(ScenePresence presence) |
@@ -1209,7 +1209,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1209 | e.Message, e.StackTrace); | 1209 | e.Message, e.StackTrace); |
1210 | } | 1210 | } |
1211 | } | 1211 | } |
1212 | } | 1212 | } |
1213 | } | 1213 | } |
1214 | 1214 | ||
1215 | public void TriggerOnIncomingSceneObject(SceneObjectGroup so) | 1215 | public void TriggerOnIncomingSceneObject(SceneObjectGroup so) |
@@ -1229,12 +1229,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1229 | "[EVENT MANAGER]: Delegate for TriggerOnIncomingSceneObject failed - continuing. {0} {1}", | 1229 | "[EVENT MANAGER]: Delegate for TriggerOnIncomingSceneObject failed - continuing. {0} {1}", |
1230 | e.Message, e.StackTrace); | 1230 | e.Message, e.StackTrace); |
1231 | } | 1231 | } |
1232 | } | 1232 | } |
1233 | } | 1233 | } |
1234 | } | 1234 | } |
1235 | 1235 | ||
1236 | public void TriggerOnRegisterCaps(UUID agentID, Caps caps) | 1236 | public void TriggerOnRegisterCaps(UUID agentID, Caps caps) |
1237 | { | 1237 | { |
1238 | RegisterCapsEvent handlerRegisterCaps = OnRegisterCaps; | 1238 | RegisterCapsEvent handlerRegisterCaps = OnRegisterCaps; |
1239 | if (handlerRegisterCaps != null) | 1239 | if (handlerRegisterCaps != null) |
1240 | { | 1240 | { |
@@ -1251,7 +1251,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1251 | e.Message, e.StackTrace); | 1251 | e.Message, e.StackTrace); |
1252 | } | 1252 | } |
1253 | } | 1253 | } |
1254 | } | 1254 | } |
1255 | } | 1255 | } |
1256 | 1256 | ||
1257 | public void TriggerOnDeregisterCaps(UUID agentID, Caps caps) | 1257 | public void TriggerOnDeregisterCaps(UUID agentID, Caps caps) |
@@ -1272,7 +1272,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1272 | e.Message, e.StackTrace); | 1272 | e.Message, e.StackTrace); |
1273 | } | 1273 | } |
1274 | } | 1274 | } |
1275 | } | 1275 | } |
1276 | } | 1276 | } |
1277 | 1277 | ||
1278 | public void TriggerOnNewInventoryItemUploadComplete(UUID agentID, UUID AssetID, String AssetName, int userlevel) | 1278 | public void TriggerOnNewInventoryItemUploadComplete(UUID agentID, UUID AssetID, String AssetName, int userlevel) |
@@ -1293,7 +1293,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1293 | e.Message, e.StackTrace); | 1293 | e.Message, e.StackTrace); |
1294 | } | 1294 | } |
1295 | } | 1295 | } |
1296 | } | 1296 | } |
1297 | } | 1297 | } |
1298 | 1298 | ||
1299 | public void TriggerLandBuy(Object sender, LandBuyArgs args) | 1299 | public void TriggerLandBuy(Object sender, LandBuyArgs args) |
@@ -1314,7 +1314,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1314 | e.Message, e.StackTrace); | 1314 | e.Message, e.StackTrace); |
1315 | } | 1315 | } |
1316 | } | 1316 | } |
1317 | } | 1317 | } |
1318 | } | 1318 | } |
1319 | 1319 | ||
1320 | public void TriggerValidateLandBuy(Object sender, LandBuyArgs args) | 1320 | public void TriggerValidateLandBuy(Object sender, LandBuyArgs args) |
@@ -1335,11 +1335,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
1335 | e.Message, e.StackTrace); | 1335 | e.Message, e.StackTrace); |
1336 | } | 1336 | } |
1337 | } | 1337 | } |
1338 | } | 1338 | } |
1339 | } | 1339 | } |
1340 | 1340 | ||
1341 | public void TriggerAtTargetEvent(uint localID, uint handle, Vector3 targetpos, Vector3 currentpos) | 1341 | public void TriggerAtTargetEvent(uint localID, uint handle, Vector3 targetpos, Vector3 currentpos) |
1342 | { | 1342 | { |
1343 | ScriptAtTargetEvent handlerScriptAtTargetEvent = OnScriptAtTargetEvent; | 1343 | ScriptAtTargetEvent handlerScriptAtTargetEvent = OnScriptAtTargetEvent; |
1344 | if (handlerScriptAtTargetEvent != null) | 1344 | if (handlerScriptAtTargetEvent != null) |
1345 | { | 1345 | { |
@@ -1356,7 +1356,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1356 | e.Message, e.StackTrace); | 1356 | e.Message, e.StackTrace); |
1357 | } | 1357 | } |
1358 | } | 1358 | } |
1359 | } | 1359 | } |
1360 | } | 1360 | } |
1361 | 1361 | ||
1362 | public void TriggerNotAtTargetEvent(uint localID) | 1362 | public void TriggerNotAtTargetEvent(uint localID) |
@@ -1377,11 +1377,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
1377 | e.Message, e.StackTrace); | 1377 | e.Message, e.StackTrace); |
1378 | } | 1378 | } |
1379 | } | 1379 | } |
1380 | } | 1380 | } |
1381 | } | 1381 | } |
1382 | 1382 | ||
1383 | public void TriggerAtRotTargetEvent(uint localID, uint handle, Quaternion targetrot, Quaternion currentrot) | 1383 | public void TriggerAtRotTargetEvent(uint localID, uint handle, Quaternion targetrot, Quaternion currentrot) |
1384 | { | 1384 | { |
1385 | ScriptAtRotTargetEvent handlerScriptAtRotTargetEvent = OnScriptAtRotTargetEvent; | 1385 | ScriptAtRotTargetEvent handlerScriptAtRotTargetEvent = OnScriptAtRotTargetEvent; |
1386 | if (handlerScriptAtRotTargetEvent != null) | 1386 | if (handlerScriptAtRotTargetEvent != null) |
1387 | { | 1387 | { |
@@ -1398,7 +1398,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1398 | e.Message, e.StackTrace); | 1398 | e.Message, e.StackTrace); |
1399 | } | 1399 | } |
1400 | } | 1400 | } |
1401 | } | 1401 | } |
1402 | } | 1402 | } |
1403 | 1403 | ||
1404 | public void TriggerNotAtRotTargetEvent(uint localID) | 1404 | public void TriggerNotAtRotTargetEvent(uint localID) |
@@ -1419,7 +1419,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1419 | e.Message, e.StackTrace); | 1419 | e.Message, e.StackTrace); |
1420 | } | 1420 | } |
1421 | } | 1421 | } |
1422 | } | 1422 | } |
1423 | } | 1423 | } |
1424 | 1424 | ||
1425 | public void TriggerRequestChangeWaterHeight(float height) | 1425 | public void TriggerRequestChangeWaterHeight(float height) |
@@ -1440,7 +1440,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1440 | e.Message, e.StackTrace); | 1440 | e.Message, e.StackTrace); |
1441 | } | 1441 | } |
1442 | } | 1442 | } |
1443 | } | 1443 | } |
1444 | } | 1444 | } |
1445 | 1445 | ||
1446 | public void TriggerAvatarKill(uint KillerObjectLocalID, ScenePresence DeadAvatar) | 1446 | public void TriggerAvatarKill(uint KillerObjectLocalID, ScenePresence DeadAvatar) |
@@ -1461,7 +1461,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1461 | e.Message, e.StackTrace); | 1461 | e.Message, e.StackTrace); |
1462 | } | 1462 | } |
1463 | } | 1463 | } |
1464 | } | 1464 | } |
1465 | } | 1465 | } |
1466 | 1466 | ||
1467 | public void TriggerSignificantClientMovement(IClientAPI client) | 1467 | public void TriggerSignificantClientMovement(IClientAPI client) |
@@ -1482,7 +1482,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1482 | e.Message, e.StackTrace); | 1482 | e.Message, e.StackTrace); |
1483 | } | 1483 | } |
1484 | } | 1484 | } |
1485 | } | 1485 | } |
1486 | } | 1486 | } |
1487 | 1487 | ||
1488 | public void TriggerOnChatFromWorld(Object sender, OSChatMessage chat) | 1488 | public void TriggerOnChatFromWorld(Object sender, OSChatMessage chat) |
@@ -1503,7 +1503,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1503 | e.Message, e.StackTrace); | 1503 | e.Message, e.StackTrace); |
1504 | } | 1504 | } |
1505 | } | 1505 | } |
1506 | } | 1506 | } |
1507 | } | 1507 | } |
1508 | 1508 | ||
1509 | public void TriggerOnChatFromClient(Object sender, OSChatMessage chat) | 1509 | public void TriggerOnChatFromClient(Object sender, OSChatMessage chat) |
@@ -1524,7 +1524,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1524 | e.Message, e.StackTrace); | 1524 | e.Message, e.StackTrace); |
1525 | } | 1525 | } |
1526 | } | 1526 | } |
1527 | } | 1527 | } |
1528 | } | 1528 | } |
1529 | 1529 | ||
1530 | public void TriggerOnChatBroadcast(Object sender, OSChatMessage chat) | 1530 | public void TriggerOnChatBroadcast(Object sender, OSChatMessage chat) |
@@ -1545,7 +1545,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1545 | e.Message, e.StackTrace); | 1545 | e.Message, e.StackTrace); |
1546 | } | 1546 | } |
1547 | } | 1547 | } |
1548 | } | 1548 | } |
1549 | } | 1549 | } |
1550 | 1550 | ||
1551 | internal void TriggerControlEvent(uint p, UUID scriptUUID, UUID avatarID, uint held, uint _changed) | 1551 | internal void TriggerControlEvent(uint p, UUID scriptUUID, UUID avatarID, uint held, uint _changed) |
@@ -1566,7 +1566,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1566 | e.Message, e.StackTrace); | 1566 | e.Message, e.StackTrace); |
1567 | } | 1567 | } |
1568 | } | 1568 | } |
1569 | } | 1569 | } |
1570 | } | 1570 | } |
1571 | 1571 | ||
1572 | public void TriggerNoticeNoLandDataFromStorage() | 1572 | public void TriggerNoticeNoLandDataFromStorage() |
@@ -1587,7 +1587,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1587 | e.Message, e.StackTrace); | 1587 | e.Message, e.StackTrace); |
1588 | } | 1588 | } |
1589 | } | 1589 | } |
1590 | } | 1590 | } |
1591 | } | 1591 | } |
1592 | 1592 | ||
1593 | public void TriggerIncomingLandDataFromStorage(List<LandData> landData) | 1593 | public void TriggerIncomingLandDataFromStorage(List<LandData> landData) |
@@ -1608,7 +1608,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1608 | e.Message, e.StackTrace); | 1608 | e.Message, e.StackTrace); |
1609 | } | 1609 | } |
1610 | } | 1610 | } |
1611 | } | 1611 | } |
1612 | } | 1612 | } |
1613 | 1613 | ||
1614 | public void TriggerSetAllowForcefulBan(bool allow) | 1614 | public void TriggerSetAllowForcefulBan(bool allow) |
@@ -1629,7 +1629,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1629 | e.Message, e.StackTrace); | 1629 | e.Message, e.StackTrace); |
1630 | } | 1630 | } |
1631 | } | 1631 | } |
1632 | } | 1632 | } |
1633 | } | 1633 | } |
1634 | 1634 | ||
1635 | public void TriggerRequestParcelPrimCountUpdate() | 1635 | public void TriggerRequestParcelPrimCountUpdate() |
@@ -1650,7 +1650,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1650 | e.Message, e.StackTrace); | 1650 | e.Message, e.StackTrace); |
1651 | } | 1651 | } |
1652 | } | 1652 | } |
1653 | } | 1653 | } |
1654 | } | 1654 | } |
1655 | 1655 | ||
1656 | public void TriggerParcelPrimCountTainted() | 1656 | public void TriggerParcelPrimCountTainted() |
@@ -1671,7 +1671,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1671 | e.Message, e.StackTrace); | 1671 | e.Message, e.StackTrace); |
1672 | } | 1672 | } |
1673 | } | 1673 | } |
1674 | } | 1674 | } |
1675 | } | 1675 | } |
1676 | 1676 | ||
1677 | // this lets us keep track of nasty script events like timer, etc. | 1677 | // this lets us keep track of nasty script events like timer, etc. |
@@ -1710,7 +1710,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1710 | e.Message, e.StackTrace); | 1710 | e.Message, e.StackTrace); |
1711 | } | 1711 | } |
1712 | } | 1712 | } |
1713 | } | 1713 | } |
1714 | } | 1714 | } |
1715 | 1715 | ||
1716 | public float GetCurrentTimeAsSunLindenHour() | 1716 | public float GetCurrentTimeAsSunLindenHour() |
@@ -1737,7 +1737,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1737 | } | 1737 | } |
1738 | 1738 | ||
1739 | public void TriggerOarFileLoaded(Guid requestId, string message) | 1739 | public void TriggerOarFileLoaded(Guid requestId, string message) |
1740 | { | 1740 | { |
1741 | OarFileLoaded handlerOarFileLoaded = OnOarFileLoaded; | 1741 | OarFileLoaded handlerOarFileLoaded = OnOarFileLoaded; |
1742 | if (handlerOarFileLoaded != null) | 1742 | if (handlerOarFileLoaded != null) |
1743 | { | 1743 | { |
@@ -1754,7 +1754,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1754 | e.Message, e.StackTrace); | 1754 | e.Message, e.StackTrace); |
1755 | } | 1755 | } |
1756 | } | 1756 | } |
1757 | } | 1757 | } |
1758 | } | 1758 | } |
1759 | 1759 | ||
1760 | public void TriggerOarFileSaved(Guid requestId, string message) | 1760 | public void TriggerOarFileSaved(Guid requestId, string message) |
@@ -1775,7 +1775,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1775 | e.Message, e.StackTrace); | 1775 | e.Message, e.StackTrace); |
1776 | } | 1776 | } |
1777 | } | 1777 | } |
1778 | } | 1778 | } |
1779 | } | 1779 | } |
1780 | 1780 | ||
1781 | public void TriggerEmptyScriptCompileQueue(int numScriptsFailed, string message) | 1781 | public void TriggerEmptyScriptCompileQueue(int numScriptsFailed, string message) |
@@ -1796,7 +1796,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1796 | e.Message, e.StackTrace); | 1796 | e.Message, e.StackTrace); |
1797 | } | 1797 | } |
1798 | } | 1798 | } |
1799 | } | 1799 | } |
1800 | } | 1800 | } |
1801 | 1801 | ||
1802 | public void TriggerScriptCollidingStart(uint localId, ColliderArgs colliders) | 1802 | public void TriggerScriptCollidingStart(uint localId, ColliderArgs colliders) |
@@ -1817,7 +1817,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1817 | e.Message, e.StackTrace); | 1817 | e.Message, e.StackTrace); |
1818 | } | 1818 | } |
1819 | } | 1819 | } |
1820 | } | 1820 | } |
1821 | } | 1821 | } |
1822 | 1822 | ||
1823 | public void TriggerScriptColliding(uint localId, ColliderArgs colliders) | 1823 | public void TriggerScriptColliding(uint localId, ColliderArgs colliders) |
@@ -1838,7 +1838,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1838 | e.Message, e.StackTrace); | 1838 | e.Message, e.StackTrace); |
1839 | } | 1839 | } |
1840 | } | 1840 | } |
1841 | } | 1841 | } |
1842 | } | 1842 | } |
1843 | 1843 | ||
1844 | public void TriggerScriptCollidingEnd(uint localId, ColliderArgs colliders) | 1844 | public void TriggerScriptCollidingEnd(uint localId, ColliderArgs colliders) |
@@ -1859,7 +1859,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1859 | e.Message, e.StackTrace); | 1859 | e.Message, e.StackTrace); |
1860 | } | 1860 | } |
1861 | } | 1861 | } |
1862 | } | 1862 | } |
1863 | } | 1863 | } |
1864 | 1864 | ||
1865 | public void TriggerScriptLandCollidingStart(uint localId, ColliderArgs colliders) | 1865 | public void TriggerScriptLandCollidingStart(uint localId, ColliderArgs colliders) |
@@ -1880,7 +1880,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1880 | e.Message, e.StackTrace); | 1880 | e.Message, e.StackTrace); |
1881 | } | 1881 | } |
1882 | } | 1882 | } |
1883 | } | 1883 | } |
1884 | } | 1884 | } |
1885 | 1885 | ||
1886 | public void TriggerScriptLandColliding(uint localId, ColliderArgs colliders) | 1886 | public void TriggerScriptLandColliding(uint localId, ColliderArgs colliders) |
@@ -1901,7 +1901,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1901 | e.Message, e.StackTrace); | 1901 | e.Message, e.StackTrace); |
1902 | } | 1902 | } |
1903 | } | 1903 | } |
1904 | } | 1904 | } |
1905 | } | 1905 | } |
1906 | 1906 | ||
1907 | public void TriggerScriptLandCollidingEnd(uint localId, ColliderArgs colliders) | 1907 | public void TriggerScriptLandCollidingEnd(uint localId, ColliderArgs colliders) |
@@ -1922,11 +1922,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
1922 | e.Message, e.StackTrace); | 1922 | e.Message, e.StackTrace); |
1923 | } | 1923 | } |
1924 | } | 1924 | } |
1925 | } | 1925 | } |
1926 | } | 1926 | } |
1927 | 1927 | ||
1928 | public void TriggerSetRootAgentScene(UUID agentID, Scene scene) | 1928 | public void TriggerSetRootAgentScene(UUID agentID, Scene scene) |
1929 | { | 1929 | { |
1930 | OnSetRootAgentSceneDelegate handlerSetRootAgentScene = OnSetRootAgentScene; | 1930 | OnSetRootAgentSceneDelegate handlerSetRootAgentScene = OnSetRootAgentScene; |
1931 | if (handlerSetRootAgentScene != null) | 1931 | if (handlerSetRootAgentScene != null) |
1932 | { | 1932 | { |
@@ -1943,7 +1943,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1943 | e.Message, e.StackTrace); | 1943 | e.Message, e.StackTrace); |
1944 | } | 1944 | } |
1945 | } | 1945 | } |
1946 | } | 1946 | } |
1947 | } | 1947 | } |
1948 | 1948 | ||
1949 | public void TriggerOnRegionUp(GridRegion otherRegion) | 1949 | public void TriggerOnRegionUp(GridRegion otherRegion) |
@@ -1964,7 +1964,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1964 | e.Message, e.StackTrace); | 1964 | e.Message, e.StackTrace); |
1965 | } | 1965 | } |
1966 | } | 1966 | } |
1967 | } | 1967 | } |
1968 | } | 1968 | } |
1969 | } | 1969 | } |
1970 | } \ No newline at end of file | 1970 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index d5ceda8..b9b16ad 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -2384,7 +2384,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2384 | AttachObject( | 2384 | AttachObject( |
2385 | sp.ControllingClient, grp.LocalId, (uint)0, grp.GroupRotation, grp.AbsolutePosition, false); | 2385 | sp.ControllingClient, grp.LocalId, (uint)0, grp.GroupRotation, grp.AbsolutePosition, false); |
2386 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); | 2386 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); |
2387 | grp.SendGroupFullUpdate(); | 2387 | grp.SendGroupFullUpdate(); |
2388 | } | 2388 | } |
2389 | else | 2389 | else |
2390 | { | 2390 | { |
diff --git a/OpenSim/Region/Framework/Scenes/SceneBase.cs b/OpenSim/Region/Framework/Scenes/SceneBase.cs index aed8640..4f6e824 100644 --- a/OpenSim/Region/Framework/Scenes/SceneBase.cs +++ b/OpenSim/Region/Framework/Scenes/SceneBase.cs | |||
@@ -262,7 +262,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
262 | /// Returns a new unallocated local ID | 262 | /// Returns a new unallocated local ID |
263 | /// </summary> | 263 | /// </summary> |
264 | /// <returns>A brand new local ID</returns> | 264 | /// <returns>A brand new local ID</returns> |
265 | protected internal uint AllocateLocalId() | 265 | public uint AllocateLocalId() |
266 | { | 266 | { |
267 | uint myID; | 267 | uint myID; |
268 | 268 | ||
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index 0132252..369552f 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs | |||
@@ -642,7 +642,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
642 | // it get cleaned up | 642 | // it get cleaned up |
643 | // | 643 | // |
644 | group.RootPart.RemFlag(PrimFlags.TemporaryOnRez); | 644 | group.RootPart.RemFlag(PrimFlags.TemporaryOnRez); |
645 | group.HasGroupChanged = false; | 645 | group.HasGroupChanged = false; |
646 | } | 646 | } |
647 | else | 647 | else |
648 | { | 648 | { |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index fe9dd9b..c5a6171 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | |||
@@ -546,7 +546,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
546 | 546 | ||
547 | if (m_rootPart.Shape.PCode != 9 || m_rootPart.Shape.State == 0) | 547 | if (m_rootPart.Shape.PCode != 9 || m_rootPart.Shape.State == 0) |
548 | m_rootPart.ParentID = 0; | 548 | m_rootPart.ParentID = 0; |
549 | if (m_rootPart.LocalId==0) | 549 | if (m_rootPart.LocalId == 0) |
550 | m_rootPart.LocalId = m_scene.AllocateLocalId(); | 550 | m_rootPart.LocalId = m_scene.AllocateLocalId(); |
551 | 551 | ||
552 | // No need to lock here since the object isn't yet in a scene | 552 | // No need to lock here since the object isn't yet in a scene |
@@ -1505,6 +1505,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1505 | /// <param name="part"></param> | 1505 | /// <param name="part"></param> |
1506 | internal void SendPartFullUpdate(IClientAPI remoteClient, SceneObjectPart part, uint clientFlags) | 1506 | internal void SendPartFullUpdate(IClientAPI remoteClient, SceneObjectPart part, uint clientFlags) |
1507 | { | 1507 | { |
1508 | // m_log.DebugFormat( | ||
1509 | // "[SOG]: Sendinging part full update to {0} for {1} {2}", remoteClient.Name, part.Name, part.LocalId); | ||
1510 | |||
1508 | if (m_rootPart.UUID == part.UUID) | 1511 | if (m_rootPart.UUID == part.UUID) |
1509 | { | 1512 | { |
1510 | if (IsAttachment) | 1513 | if (IsAttachment) |
@@ -2297,7 +2300,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
2297 | 2300 | ||
2298 | AttachToBackup(); | 2301 | AttachToBackup(); |
2299 | 2302 | ||
2300 | |||
2301 | // Here's the deal, this is ABSOLUTELY CRITICAL so the physics scene gets the update about the | 2303 | // Here's the deal, this is ABSOLUTELY CRITICAL so the physics scene gets the update about the |
2302 | // position of linkset prims. IF YOU CHANGE THIS, YOU MUST TEST colliding with just linked and | 2304 | // position of linkset prims. IF YOU CHANGE THIS, YOU MUST TEST colliding with just linked and |
2303 | // unmoved prims! | 2305 | // unmoved prims! |
@@ -2312,9 +2314,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
2312 | /// an independent SceneObjectGroup. | 2314 | /// an independent SceneObjectGroup. |
2313 | /// </summary> | 2315 | /// </summary> |
2314 | /// <param name="partID"></param> | 2316 | /// <param name="partID"></param> |
2315 | public void DelinkFromGroup(uint partID) | 2317 | /// <returns>The object group of the newly delinked prim. Null if part could not be found</returns> |
2318 | public SceneObjectGroup DelinkFromGroup(uint partID) | ||
2316 | { | 2319 | { |
2317 | DelinkFromGroup(partID, true); | 2320 | return DelinkFromGroup(partID, true); |
2318 | } | 2321 | } |
2319 | 2322 | ||
2320 | /// <summary> | 2323 | /// <summary> |
@@ -2323,28 +2326,39 @@ namespace OpenSim.Region.Framework.Scenes | |||
2323 | /// </summary> | 2326 | /// </summary> |
2324 | /// <param name="partID"></param> | 2327 | /// <param name="partID"></param> |
2325 | /// <param name="sendEvents"></param> | 2328 | /// <param name="sendEvents"></param> |
2326 | public void DelinkFromGroup(uint partID, bool sendEvents) | 2329 | /// <returns>The object group of the newly delinked prim. Null if part could not be found</returns> |
2330 | public SceneObjectGroup DelinkFromGroup(uint partID, bool sendEvents) | ||
2327 | { | 2331 | { |
2328 | SceneObjectPart linkPart = GetChildPart(partID); | 2332 | SceneObjectPart linkPart = GetChildPart(partID); |
2329 | 2333 | ||
2330 | if (linkPart != null) | 2334 | if (linkPart != null) |
2331 | { | 2335 | { |
2332 | DelinkFromGroup(linkPart, sendEvents); | 2336 | return DelinkFromGroup(linkPart, sendEvents); |
2333 | } | 2337 | } |
2334 | else | 2338 | else |
2335 | { | 2339 | { |
2336 | m_log.InfoFormat("[SCENE OBJECT GROUP]: " + | 2340 | m_log.WarnFormat("[SCENE OBJECT GROUP]: " + |
2337 | "DelinkFromGroup(): Child prim {0} not found in object {1}, {2}", | 2341 | "DelinkFromGroup(): Child prim {0} not found in object {1}, {2}", |
2338 | partID, LocalId, UUID); | 2342 | partID, LocalId, UUID); |
2343 | |||
2344 | return null; | ||
2339 | } | 2345 | } |
2340 | } | 2346 | } |
2341 | 2347 | ||
2342 | public void DelinkFromGroup(SceneObjectPart linkPart, bool sendEvents) | 2348 | /// <summary> |
2349 | /// Delink the given prim from this group. The delinked prim is established as | ||
2350 | /// an independent SceneObjectGroup. | ||
2351 | /// </summary> | ||
2352 | /// <param name="partID"></param> | ||
2353 | /// <param name="sendEvents"></param> | ||
2354 | /// <returns>The object group of the newly delinked prim.</returns> | ||
2355 | public SceneObjectGroup DelinkFromGroup(SceneObjectPart linkPart, bool sendEvents) | ||
2343 | { | 2356 | { |
2344 | linkPart.ClearUndoState(); | ||
2345 | // m_log.DebugFormat( | 2357 | // m_log.DebugFormat( |
2346 | // "[SCENE OBJECT GROUP]: Delinking part {0}, {1} from group with root part {2}, {3}", | 2358 | // "[SCENE OBJECT GROUP]: Delinking part {0}, {1} from group with root part {2}, {3}", |
2347 | // linkPart.Name, linkPart.UUID, RootPart.Name, RootPart.UUID); | 2359 | // linkPart.Name, linkPart.UUID, RootPart.Name, RootPart.UUID); |
2360 | |||
2361 | linkPart.ClearUndoState(); | ||
2348 | 2362 | ||
2349 | Quaternion worldRot = linkPart.GetWorldRotation(); | 2363 | Quaternion worldRot = linkPart.GetWorldRotation(); |
2350 | 2364 | ||
@@ -2397,6 +2411,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2397 | 2411 | ||
2398 | //HasGroupChanged = true; | 2412 | //HasGroupChanged = true; |
2399 | //ScheduleGroupForFullUpdate(); | 2413 | //ScheduleGroupForFullUpdate(); |
2414 | |||
2415 | return objectGroup; | ||
2400 | } | 2416 | } |
2401 | 2417 | ||
2402 | /// <summary> | 2418 | /// <summary> |
@@ -2435,7 +2451,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
2435 | 2451 | ||
2436 | part.LinkNum = linkNum; | 2452 | part.LinkNum = linkNum; |
2437 | 2453 | ||
2438 | |||
2439 | part.OffsetPosition = part.GroupPosition - AbsolutePosition; | 2454 | part.OffsetPosition = part.GroupPosition - AbsolutePosition; |
2440 | 2455 | ||
2441 | Quaternion rootRotation = m_rootPart.RotationOffset; | 2456 | Quaternion rootRotation = m_rootPart.RotationOffset; |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index d339208..5c283bc 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | |||
@@ -4531,7 +4531,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4531 | else | 4531 | else |
4532 | { | 4532 | { |
4533 | // m_log.DebugFormat( | 4533 | // m_log.DebugFormat( |
4534 | // "[SCENE OBJECT PART]: Scheduling part {0} {1} for full update in aggregateScriptEvents()", Name, LocalId); | 4534 | // "[SCENE OBJECT PART]: Scheduling part {0} {1} for full update in aggregateScriptEvents()", Name, LocalId); |
4535 | ScheduleFullUpdate(); | 4535 | ScheduleFullUpdate(); |
4536 | } | 4536 | } |
4537 | } | 4537 | } |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index d0de513..04e3221 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | |||
@@ -313,7 +313,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
313 | } | 313 | } |
314 | ); | 314 | ); |
315 | } | 315 | } |
316 | } | 316 | } |
317 | 317 | ||
318 | private void RestoreSavedScriptState(UUID oldID, UUID newID) | 318 | private void RestoreSavedScriptState(UUID oldID, UUID newID) |
319 | { | 319 | { |
@@ -578,7 +578,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
578 | m_items.TryGetValue(itemId, out item); | 578 | m_items.TryGetValue(itemId, out item); |
579 | 579 | ||
580 | return item; | 580 | return item; |
581 | } | 581 | } |
582 | 582 | ||
583 | /// <summary> | 583 | /// <summary> |
584 | /// Get inventory items by name. | 584 | /// Get inventory items by name. |
@@ -587,7 +587,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
587 | /// <returns> | 587 | /// <returns> |
588 | /// A list of inventory items with that name. | 588 | /// A list of inventory items with that name. |
589 | /// If no inventory item has that name then an empty list is returned. | 589 | /// If no inventory item has that name then an empty list is returned. |
590 | /// </returns> | 590 | /// </returns> |
591 | public IList<TaskInventoryItem> GetInventoryItems(string name) | 591 | public IList<TaskInventoryItem> GetInventoryItems(string name) |
592 | { | 592 | { |
593 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(); | 593 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(); |
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 6b6fa7c..af9afa6 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -650,7 +650,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
650 | #region Constructor(s) | 650 | #region Constructor(s) |
651 | 651 | ||
652 | public ScenePresence() | 652 | public ScenePresence() |
653 | { | 653 | { |
654 | m_sendCourseLocationsMethod = SendCoarseLocationsDefault; | 654 | m_sendCourseLocationsMethod = SendCoarseLocationsDefault; |
655 | CreateSceneViewer(); | 655 | CreateSceneViewer(); |
656 | m_animator = new ScenePresenceAnimator(this); | 656 | m_animator = new ScenePresenceAnimator(this); |
@@ -1241,14 +1241,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1241 | } | 1241 | } |
1242 | else | 1242 | else |
1243 | { | 1243 | { |
1244 | if (m_pos.X < 0) | ||
1245 | m_pos.X = 128; | ||
1246 | if (m_pos.Y < 0) | ||
1247 | m_pos.Y = 128; | ||
1248 | if (m_pos.X > Scene.WestBorders[0].BorderLine.X) | ||
1249 | m_pos.X = 128; | ||
1250 | if (m_pos.Y > Scene.NorthBorders[0].BorderLine.Y) | ||
1251 | m_pos.Y = 128; | ||
1252 | m_LastFinitePos = m_pos; | 1244 | m_LastFinitePos = m_pos; |
1253 | } | 1245 | } |
1254 | 1246 | ||
@@ -2818,16 +2810,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
2818 | { | 2810 | { |
2819 | if (!needsTransit) | 2811 | if (!needsTransit) |
2820 | { | 2812 | { |
2821 | Vector3 pos = AbsolutePosition; | 2813 | if (m_requestedSitTargetUUID == UUID.Zero) |
2822 | if (AbsolutePosition.X < 0) | 2814 | { |
2823 | pos.X += Velocity.Y; | 2815 | Vector3 pos = AbsolutePosition; |
2824 | else if (AbsolutePosition.X > Constants.RegionSize) | 2816 | if (AbsolutePosition.X < 0) |
2825 | pos.X -= Velocity.Y; | 2817 | pos.X += Velocity.X; |
2826 | if (AbsolutePosition.Y < 0) | 2818 | else if (AbsolutePosition.X > Constants.RegionSize) |
2827 | pos.Y += Velocity.Y; | 2819 | pos.X -= Velocity.X; |
2828 | else if (AbsolutePosition.Y > Constants.RegionSize) | 2820 | if (AbsolutePosition.Y < 0) |
2829 | pos.Y -= Velocity.Y; | 2821 | pos.Y += Velocity.Y; |
2830 | AbsolutePosition = pos; | 2822 | else if (AbsolutePosition.Y > Constants.RegionSize) |
2823 | pos.Y -= Velocity.Y; | ||
2824 | AbsolutePosition = pos; | ||
2825 | } | ||
2831 | } | 2826 | } |
2832 | } | 2827 | } |
2833 | else if (neighbor > 0) | 2828 | else if (neighbor > 0) |
@@ -3292,7 +3287,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3292 | m_physicsActor.OnCollisionUpdate += PhysicsCollisionUpdate; | 3287 | m_physicsActor.OnCollisionUpdate += PhysicsCollisionUpdate; |
3293 | m_physicsActor.OnOutOfBounds += OutOfBoundsCall; // Called for PhysicsActors when there's something wrong | 3288 | m_physicsActor.OnOutOfBounds += OutOfBoundsCall; // Called for PhysicsActors when there's something wrong |
3294 | m_physicsActor.SubscribeEvents(500); | 3289 | m_physicsActor.SubscribeEvents(500); |
3295 | m_physicsActor.LocalID = LocalId; | 3290 | m_physicsActor.LocalID = LocalId; |
3296 | } | 3291 | } |
3297 | 3292 | ||
3298 | private void OutOfBoundsCall(Vector3 pos) | 3293 | private void OutOfBoundsCall(Vector3 pos) |
@@ -3384,7 +3379,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3384 | } | 3379 | } |
3385 | if (m_health <= 0) | 3380 | if (m_health <= 0) |
3386 | m_scene.EventManager.TriggerAvatarKill(killerObj, this); | 3381 | m_scene.EventManager.TriggerAvatarKill(killerObj, this); |
3387 | } | 3382 | } |
3388 | } | 3383 | } |
3389 | 3384 | ||
3390 | public void setHealthWithUpdate(float health) | 3385 | public void setHealthWithUpdate(float health) |
diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs index 51341de..242bc3f 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs | |||
@@ -50,7 +50,6 @@ using OpenSim.Region.Framework.Scenes; | |||
50 | using Caps = OpenSim.Framework.Capabilities.Caps; | 50 | using Caps = OpenSim.Framework.Capabilities.Caps; |
51 | using System.Text.RegularExpressions; | 51 | using System.Text.RegularExpressions; |
52 | 52 | ||
53 | |||
54 | namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice | 53 | namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice |
55 | { | 54 | { |
56 | public class FreeSwitchVoiceModule : IRegionModule, IVoiceModule | 55 | public class FreeSwitchVoiceModule : IRegionModule, IVoiceModule |
@@ -76,7 +75,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice | |||
76 | // SLVoice client will do a GET on this prefix | 75 | // SLVoice client will do a GET on this prefix |
77 | private static string m_freeSwitchAPIPrefix; | 76 | private static string m_freeSwitchAPIPrefix; |
78 | 77 | ||
79 | // We need to return some information to SLVoice | 78 | // We need to return some information to SLVoice |
80 | // figured those out via curl | 79 | // figured those out via curl |
81 | // http://vd1.vivox.com/api2/viv_get_prelogin.php | 80 | // http://vd1.vivox.com/api2/viv_get_prelogin.php |
82 | // | 81 | // |
@@ -102,9 +101,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice | |||
102 | 101 | ||
103 | private readonly Dictionary<string, string> m_UUIDName = new Dictionary<string, string>(); | 102 | private readonly Dictionary<string, string> m_UUIDName = new Dictionary<string, string>(); |
104 | private Dictionary<string, string> m_ParcelAddress = new Dictionary<string, string>(); | 103 | private Dictionary<string, string> m_ParcelAddress = new Dictionary<string, string>(); |
105 | 104 | ||
106 | private Scene m_scene; | 105 | private Scene m_scene; |
107 | 106 | ||
108 | 107 | ||
109 | private IConfig m_config; | 108 | private IConfig m_config; |
110 | 109 | ||
@@ -136,9 +135,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice | |||
136 | m_freeSwitchServerUser = m_config.GetString("freeswitch_server_user", String.Empty); | 135 | m_freeSwitchServerUser = m_config.GetString("freeswitch_server_user", String.Empty); |
137 | m_freeSwitchServerPass = m_config.GetString("freeswitch_server_pass", String.Empty); | 136 | m_freeSwitchServerPass = m_config.GetString("freeswitch_server_pass", String.Empty); |
138 | m_freeSwitchAPIPrefix = m_config.GetString("freeswitch_api_prefix", String.Empty); | 137 | m_freeSwitchAPIPrefix = m_config.GetString("freeswitch_api_prefix", String.Empty); |
139 | 138 | ||
140 | // XXX: get IP address of HTTP server. (This can be this OpenSim server or another, or could be a dedicated grid service or may live on the freeswitch server) | 139 | // XXX: get IP address of HTTP server. (This can be this OpenSim server or another, or could be a dedicated grid service or may live on the freeswitch server) |
141 | 140 | ||
142 | string serviceIP = m_config.GetString("freeswitch_service_server", String.Empty); | 141 | string serviceIP = m_config.GetString("freeswitch_service_server", String.Empty); |
143 | int servicePort = m_config.GetInt("freeswitch_service_port", 80); | 142 | int servicePort = m_config.GetInt("freeswitch_service_port", 80); |
144 | IPAddress serviceIPAddress = IPAddress.Parse(serviceIP); | 143 | IPAddress serviceIPAddress = IPAddress.Parse(serviceIP); |
@@ -156,7 +155,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice | |||
156 | // m_freeSwitchSubscribeRetry = m_config.GetInt("freeswitch_subscribe_retry", 120); | 155 | // m_freeSwitchSubscribeRetry = m_config.GetInt("freeswitch_subscribe_retry", 120); |
157 | m_freeSwitchUrlResetPassword = m_config.GetString("freeswitch_password_reset_url", String.Empty); | 156 | m_freeSwitchUrlResetPassword = m_config.GetString("freeswitch_password_reset_url", String.Empty); |
158 | m_freeSwitchContext = m_config.GetString("freeswitch_context", "default"); | 157 | m_freeSwitchContext = m_config.GetString("freeswitch_context", "default"); |
159 | 158 | ||
160 | if (String.IsNullOrEmpty(m_freeSwitchServerUser) || | 159 | if (String.IsNullOrEmpty(m_freeSwitchServerUser) || |
161 | String.IsNullOrEmpty(m_freeSwitchServerPass) || | 160 | String.IsNullOrEmpty(m_freeSwitchServerPass) || |
162 | String.IsNullOrEmpty(m_freeSwitchRealm) || | 161 | String.IsNullOrEmpty(m_freeSwitchRealm) || |
@@ -182,9 +181,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice | |||
182 | { | 181 | { |
183 | MainServer.Instance.AddHTTPHandler(String.Format("{0}/viv_get_prelogin.php", m_freeSwitchAPIPrefix), | 182 | MainServer.Instance.AddHTTPHandler(String.Format("{0}/viv_get_prelogin.php", m_freeSwitchAPIPrefix), |
184 | FreeSwitchSLVoiceGetPreloginHTTPHandler); | 183 | FreeSwitchSLVoiceGetPreloginHTTPHandler); |
185 | 184 | ||
186 | // RestStreamHandler h = new | 185 | // RestStreamHandler h = new |
187 | // RestStreamHandler("GET", | 186 | // RestStreamHandler("GET", |
188 | // String.Format("{0}/viv_get_prelogin.php", m_freeSwitchAPIPrefix), FreeSwitchSLVoiceGetPreloginHTTPHandler); | 187 | // String.Format("{0}/viv_get_prelogin.php", m_freeSwitchAPIPrefix), FreeSwitchSLVoiceGetPreloginHTTPHandler); |
189 | // MainServer.Instance.AddStreamHandler(h); | 188 | // MainServer.Instance.AddStreamHandler(h); |
190 | 189 | ||
@@ -202,13 +201,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice | |||
202 | MainServer.Instance.AddHTTPHandler(String.Format("{0}/viv_buddy.php", m_freeSwitchAPIPrefix), | 201 | MainServer.Instance.AddHTTPHandler(String.Format("{0}/viv_buddy.php", m_freeSwitchAPIPrefix), |
203 | FreeSwitchSLVoiceBuddyHTTPHandler); | 202 | FreeSwitchSLVoiceBuddyHTTPHandler); |
204 | } | 203 | } |
205 | |||
206 | |||
207 | |||
208 | 204 | ||
209 | |||
210 | m_log.InfoFormat("[FreeSwitchVoice] using FreeSwitch server {0}", m_freeSwitchRealm); | 205 | m_log.InfoFormat("[FreeSwitchVoice] using FreeSwitch server {0}", m_freeSwitchRealm); |
211 | 206 | ||
212 | m_FreeSwitchDirectory = new FreeSwitchDirectory(); | 207 | m_FreeSwitchDirectory = new FreeSwitchDirectory(); |
213 | m_FreeSwitchDialplan = new FreeSwitchDialplan(); | 208 | m_FreeSwitchDialplan = new FreeSwitchDialplan(); |
214 | 209 | ||
@@ -225,7 +220,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice | |||
225 | } | 220 | } |
226 | } | 221 | } |
227 | 222 | ||
228 | if (m_pluginEnabled) | 223 | if (m_pluginEnabled) |
229 | { | 224 | { |
230 | // we need to capture scene in an anonymous method | 225 | // we need to capture scene in an anonymous method |
231 | // here as we need it later in the callbacks | 226 | // here as we need it later in the callbacks |
@@ -233,8 +228,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice | |||
233 | { | 228 | { |
234 | OnRegisterCaps(scene, agentID, caps); | 229 | OnRegisterCaps(scene, agentID, caps); |
235 | }; | 230 | }; |
236 | |||
237 | |||
238 | 231 | ||
239 | try | 232 | try |
240 | { | 233 | { |
@@ -254,16 +247,15 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice | |||
254 | m_log.Error("[FreeSwitchVoice]: Certificate validation handler change not supported. You may get ssl certificate validation errors teleporting from your region to some SSL regions."); | 247 | m_log.Error("[FreeSwitchVoice]: Certificate validation handler change not supported. You may get ssl certificate validation errors teleporting from your region to some SSL regions."); |
255 | } | 248 | } |
256 | } | 249 | } |
257 | |||
258 | } | 250 | } |
259 | } | 251 | } |
260 | 252 | ||
261 | public void PostInitialise() | 253 | public void PostInitialise() |
262 | { | 254 | { |
263 | if (m_pluginEnabled) | 255 | if (m_pluginEnabled) |
264 | { | 256 | { |
265 | m_log.Info("[FreeSwitchVoice] registering IVoiceModule with the scene"); | 257 | m_log.Info("[FreeSwitchVoice] registering IVoiceModule with the scene"); |
266 | 258 | ||
267 | // register the voice interface for this module, so the script engine can call us | 259 | // register the voice interface for this module, so the script engine can call us |
268 | m_scene.RegisterModuleInterface<IVoiceModule>(this); | 260 | m_scene.RegisterModuleInterface<IVoiceModule>(this); |
269 | } | 261 | } |
@@ -282,15 +274,15 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice | |||
282 | { | 274 | { |
283 | get { return true; } | 275 | get { return true; } |
284 | } | 276 | } |
285 | 277 | ||
286 | // <summary> | 278 | // <summary> |
287 | // implementation of IVoiceModule, called by osSetParcelSIPAddress script function | 279 | // implementation of IVoiceModule, called by osSetParcelSIPAddress script function |
288 | // </summary> | 280 | // </summary> |
289 | public void setLandSIPAddress(string SIPAddress,UUID GlobalID) | 281 | public void setLandSIPAddress(string SIPAddress,UUID GlobalID) |
290 | { | 282 | { |
291 | m_log.DebugFormat("[FreeSwitchVoice]: setLandSIPAddress parcel id {0}: setting sip address {1}", | 283 | m_log.DebugFormat("[FreeSwitchVoice]: setLandSIPAddress parcel id {0}: setting sip address {1}", |
292 | GlobalID, SIPAddress); | 284 | GlobalID, SIPAddress); |
293 | 285 | ||
294 | lock (m_ParcelAddress) | 286 | lock (m_ParcelAddress) |
295 | { | 287 | { |
296 | if (m_ParcelAddress.ContainsKey(GlobalID.ToString())) | 288 | if (m_ParcelAddress.ContainsKey(GlobalID.ToString())) |
@@ -303,18 +295,18 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice | |||
303 | } | 295 | } |
304 | } | 296 | } |
305 | } | 297 | } |
306 | 298 | ||
307 | // <summary> | 299 | // <summary> |
308 | // OnRegisterCaps is invoked via the scene.EventManager | 300 | // OnRegisterCaps is invoked via the scene.EventManager |
309 | // everytime OpenSim hands out capabilities to a client | 301 | // everytime OpenSim hands out capabilities to a client |
310 | // (login, region crossing). We contribute two capabilities to | 302 | // (login, region crossing). We contribute two capabilities to |
311 | // the set of capabilities handed back to the client: | 303 | // the set of capabilities handed back to the client: |
312 | // ProvisionVoiceAccountRequest and ParcelVoiceInfoRequest. | 304 | // ProvisionVoiceAccountRequest and ParcelVoiceInfoRequest. |
313 | // | 305 | // |
314 | // ProvisionVoiceAccountRequest allows the client to obtain | 306 | // ProvisionVoiceAccountRequest allows the client to obtain |
315 | // the voice account credentials for the avatar it is | 307 | // the voice account credentials for the avatar it is |
316 | // controlling (e.g., user name, password, etc). | 308 | // controlling (e.g., user name, password, etc). |
317 | // | 309 | // |
318 | // ParcelVoiceInfoRequest is invoked whenever the client | 310 | // ParcelVoiceInfoRequest is invoked whenever the client |
319 | // changes from one region or parcel to another. | 311 | // changes from one region or parcel to another. |
320 | // | 312 | // |
@@ -371,7 +363,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice | |||
371 | { | 363 | { |
372 | System.Threading.Thread.Sleep(2000); | 364 | System.Threading.Thread.Sleep(2000); |
373 | avatar = scene.GetScenePresence(agentID); | 365 | avatar = scene.GetScenePresence(agentID); |
374 | 366 | ||
375 | if (avatar == null) | 367 | if (avatar == null) |
376 | return "<llsd>undef</llsd>"; | 368 | return "<llsd>undef</llsd>"; |
377 | } | 369 | } |
@@ -407,8 +399,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice | |||
407 | // new LLSDVoiceAccountResponse(agentname, password, m_freeSwitchRealm, "http://etsvc02.hursley.ibm.com/api"); | 399 | // new LLSDVoiceAccountResponse(agentname, password, m_freeSwitchRealm, "http://etsvc02.hursley.ibm.com/api"); |
408 | LLSDVoiceAccountResponse voiceAccountResponse = | 400 | LLSDVoiceAccountResponse voiceAccountResponse = |
409 | new LLSDVoiceAccountResponse(agentname, password, m_freeSwitchRealm, | 401 | new LLSDVoiceAccountResponse(agentname, password, m_freeSwitchRealm, |
410 | String.Format("http://{0}:{1}{2}/", m_openSimWellKnownHTTPAddress, | 402 | String.Format("http://{0}:{1}{2}/", m_openSimWellKnownHTTPAddress, |
411 | m_freeSwitchServicePort, m_freeSwitchAPIPrefix)); | 403 | m_freeSwitchServicePort, m_freeSwitchAPIPrefix)); |
412 | 404 | ||
413 | string r = LLSDHelpers.SerialiseLLSDReply(voiceAccountResponse); | 405 | string r = LLSDHelpers.SerialiseLLSDReply(voiceAccountResponse); |
414 | 406 | ||
@@ -442,7 +434,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice | |||
442 | string avatarName = avatar.Name; | 434 | string avatarName = avatar.Name; |
443 | 435 | ||
444 | // - check whether we have a region channel in our cache | 436 | // - check whether we have a region channel in our cache |
445 | // - if not: | 437 | // - if not: |
446 | // create it and cache it | 438 | // create it and cache it |
447 | // - send it to the client | 439 | // - send it to the client |
448 | // - send channel_uri: as "sip:regionID@m_sipDomain" | 440 | // - send channel_uri: as "sip:regionID@m_sipDomain" |
@@ -451,12 +443,10 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice | |||
451 | LLSDParcelVoiceInfoResponse parcelVoiceInfo; | 443 | LLSDParcelVoiceInfoResponse parcelVoiceInfo; |
452 | string channelUri; | 444 | string channelUri; |
453 | 445 | ||
454 | if (null == scene.LandChannel) | 446 | if (null == scene.LandChannel) |
455 | throw new Exception(String.Format("region \"{0}\": avatar \"{1}\": land data not yet available", | 447 | throw new Exception(String.Format("region \"{0}\": avatar \"{1}\": land data not yet available", |
456 | scene.RegionInfo.RegionName, avatarName)); | 448 | scene.RegionInfo.RegionName, avatarName)); |
457 | 449 | ||
458 | |||
459 | |||
460 | // get channel_uri: check first whether estate | 450 | // get channel_uri: check first whether estate |
461 | // settings allow voice, then whether parcel allows | 451 | // settings allow voice, then whether parcel allows |
462 | // voice, if all do retrieve or obtain the parcel | 452 | // voice, if all do retrieve or obtain the parcel |
@@ -493,22 +483,21 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice | |||
493 | parcelVoiceInfo = new LLSDParcelVoiceInfoResponse(scene.RegionInfo.RegionName, land.LocalID, creds); | 483 | parcelVoiceInfo = new LLSDParcelVoiceInfoResponse(scene.RegionInfo.RegionName, land.LocalID, creds); |
494 | string r = LLSDHelpers.SerialiseLLSDReply(parcelVoiceInfo); | 484 | string r = LLSDHelpers.SerialiseLLSDReply(parcelVoiceInfo); |
495 | 485 | ||
496 | m_log.DebugFormat("[FreeSwitchVoice][PARCELVOICE]: region \"{0}\": Parcel \"{1}\" ({2}): avatar \"{3}\": {4}", | 486 | m_log.DebugFormat("[FreeSwitchVoice][PARCELVOICE]: region \"{0}\": Parcel \"{1}\" ({2}): avatar \"{3}\": {4}", |
497 | scene.RegionInfo.RegionName, land.Name, land.LocalID, avatarName, r); | 487 | scene.RegionInfo.RegionName, land.Name, land.LocalID, avatarName, r); |
498 | return r; | 488 | return r; |
499 | } | 489 | } |
500 | catch (Exception e) | 490 | catch (Exception e) |
501 | { | 491 | { |
502 | m_log.ErrorFormat("[FreeSwitchVoice][PARCELVOICE]: region \"{0}\": avatar \"{1}\": {2}, retry later", | 492 | m_log.ErrorFormat("[FreeSwitchVoice][PARCELVOICE]: region \"{0}\": avatar \"{1}\": {2}, retry later", |
503 | scene.RegionInfo.RegionName, avatarName, e.Message); | 493 | scene.RegionInfo.RegionName, avatarName, e.Message); |
504 | m_log.DebugFormat("[FreeSwitchVoice][PARCELVOICE]: region \"{0}\": avatar \"{1}\": {2} failed", | 494 | m_log.DebugFormat("[FreeSwitchVoice][PARCELVOICE]: region \"{0}\": avatar \"{1}\": {2} failed", |
505 | scene.RegionInfo.RegionName, avatarName, e.ToString()); | 495 | scene.RegionInfo.RegionName, avatarName, e.ToString()); |
506 | 496 | ||
507 | return "<llsd>undef</llsd>"; | 497 | return "<llsd>undef</llsd>"; |
508 | } | 498 | } |
509 | } | 499 | } |
510 | 500 | ||
511 | |||
512 | /// <summary> | 501 | /// <summary> |
513 | /// Callback for a client request for ChatSessionRequest | 502 | /// Callback for a client request for ChatSessionRequest |
514 | /// </summary> | 503 | /// </summary> |
@@ -550,7 +539,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice | |||
550 | string fwdresponsestr = ""; | 539 | string fwdresponsestr = ""; |
551 | int fwdresponsecode = 200; | 540 | int fwdresponsecode = 200; |
552 | string fwdresponsecontenttype = "text/xml"; | 541 | string fwdresponsecontenttype = "text/xml"; |
553 | |||
554 | 542 | ||
555 | HttpWebRequest forwardreq = (HttpWebRequest)WebRequest.Create(forwardaddress); | 543 | HttpWebRequest forwardreq = (HttpWebRequest)WebRequest.Create(forwardaddress); |
556 | forwardreq.Method = method; | 544 | forwardreq.Method = method; |
@@ -577,7 +565,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice | |||
577 | response["content_type"] = fwdresponsecontenttype; | 565 | response["content_type"] = fwdresponsecontenttype; |
578 | response["str_response_string"] = fwdresponsestr; | 566 | response["str_response_string"] = fwdresponsestr; |
579 | response["int_response_code"] = fwdresponsecode; | 567 | response["int_response_code"] = fwdresponsecode; |
580 | 568 | ||
581 | return response; | 569 | return response; |
582 | } | 570 | } |
583 | 571 | ||
@@ -585,11 +573,11 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice | |||
585 | public Hashtable FreeSwitchSLVoiceGetPreloginHTTPHandler(Hashtable request) | 573 | public Hashtable FreeSwitchSLVoiceGetPreloginHTTPHandler(Hashtable request) |
586 | { | 574 | { |
587 | m_log.Debug("[FreeSwitchVoice] FreeSwitchSLVoiceGetPreloginHTTPHandler called"); | 575 | m_log.Debug("[FreeSwitchVoice] FreeSwitchSLVoiceGetPreloginHTTPHandler called"); |
588 | 576 | ||
589 | Hashtable response = new Hashtable(); | 577 | Hashtable response = new Hashtable(); |
590 | response["content_type"] = "text/xml"; | 578 | response["content_type"] = "text/xml"; |
591 | response["keepalive"] = false; | 579 | response["keepalive"] = false; |
592 | 580 | ||
593 | response["str_response_string"] = String.Format( | 581 | response["str_response_string"] = String.Format( |
594 | "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n" + | 582 | "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n" + |
595 | "<VCConfiguration>\r\n"+ | 583 | "<VCConfiguration>\r\n"+ |
@@ -607,9 +595,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice | |||
607 | "</VCConfiguration>", | 595 | "</VCConfiguration>", |
608 | m_freeSwitchRealm, m_freeSwitchSIPProxy, m_freeSwitchAttemptUseSTUN, | 596 | m_freeSwitchRealm, m_freeSwitchSIPProxy, m_freeSwitchAttemptUseSTUN, |
609 | m_freeSwitchEchoServer, m_freeSwitchEchoPort, | 597 | m_freeSwitchEchoServer, m_freeSwitchEchoPort, |
610 | m_freeSwitchDefaultWellKnownIP, m_freeSwitchDefaultTimeout, | 598 | m_freeSwitchDefaultWellKnownIP, m_freeSwitchDefaultTimeout, |
611 | m_freeSwitchUrlResetPassword, ""); | 599 | m_freeSwitchUrlResetPassword, ""); |
612 | 600 | ||
613 | response["int_response_code"] = 200; | 601 | response["int_response_code"] = 200; |
614 | 602 | ||
615 | m_log.DebugFormat("[FreeSwitchVoice] FreeSwitchSLVoiceGetPreloginHTTPHandler return {0}",response["str_response_string"]); | 603 | m_log.DebugFormat("[FreeSwitchVoice] FreeSwitchSLVoiceGetPreloginHTTPHandler return {0}",response["str_response_string"]); |
@@ -624,7 +612,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice | |||
624 | response["content-type"] = "text/xml"; | 612 | response["content-type"] = "text/xml"; |
625 | 613 | ||
626 | Hashtable requestBody = parseRequestBody((string)request["body"]); | 614 | Hashtable requestBody = parseRequestBody((string)request["body"]); |
627 | 615 | ||
628 | if (!requestBody.ContainsKey("auth_token")) | 616 | if (!requestBody.ContainsKey("auth_token")) |
629 | return response; | 617 | return response; |
630 | 618 | ||
@@ -632,7 +620,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice | |||
632 | //string[] auth_tokenvals = auth_token.Split(':'); | 620 | //string[] auth_tokenvals = auth_token.Split(':'); |
633 | //string username = auth_tokenvals[0]; | 621 | //string username = auth_tokenvals[0]; |
634 | int strcount = 0; | 622 | int strcount = 0; |
635 | 623 | ||
636 | string[] ids = new string[strcount]; | 624 | string[] ids = new string[strcount]; |
637 | 625 | ||
638 | int iter = -1; | 626 | int iter = -1; |
@@ -648,7 +636,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice | |||
648 | } | 636 | } |
649 | StringBuilder resp = new StringBuilder(); | 637 | StringBuilder resp = new StringBuilder(); |
650 | resp.Append("<?xml version=\"1.0\" encoding=\"iso-8859-1\" ?><response xmlns=\"http://www.vivox.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation= \"/xsd/buddy_list.xsd\">"); | 638 | resp.Append("<?xml version=\"1.0\" encoding=\"iso-8859-1\" ?><response xmlns=\"http://www.vivox.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation= \"/xsd/buddy_list.xsd\">"); |
651 | 639 | ||
652 | resp.Append(string.Format(@"<level0> | 640 | resp.Append(string.Format(@"<level0> |
653 | <status>OK</status> | 641 | <status>OK</status> |
654 | <cookie_name>lib_session</cookie_name> | 642 | <cookie_name>lib_session</cookie_name> |
@@ -678,7 +666,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice | |||
678 | <b2g_group_id></b2g_group_id> | 666 | <b2g_group_id></b2g_group_id> |
679 | </level3>", ids[i],i,m_freeSwitchRealm,dt)); | 667 | </level3>", ids[i],i,m_freeSwitchRealm,dt)); |
680 | } | 668 | } |
681 | 669 | ||
682 | resp.Append("</buddies><groups></groups></body></level0></response>"); | 670 | resp.Append("</buddies><groups></groups></body></level0></response>"); |
683 | 671 | ||
684 | response["str_response_string"] = resp.ToString(); | 672 | response["str_response_string"] = resp.ToString(); |
@@ -694,7 +682,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice | |||
694 | string requestbody = (string)request["body"]; | 682 | string requestbody = (string)request["body"]; |
695 | string uri = (string)request["uri"]; | 683 | string uri = (string)request["uri"]; |
696 | string contenttype = (string)request["content-type"]; | 684 | string contenttype = (string)request["content-type"]; |
697 | 685 | ||
698 | Hashtable requestBody = parseRequestBody((string)request["body"]); | 686 | Hashtable requestBody = parseRequestBody((string)request["body"]); |
699 | 687 | ||
700 | //string pwd = (string) requestBody["pwd"]; | 688 | //string pwd = (string) requestBody["pwd"]; |
@@ -712,7 +700,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice | |||
712 | pos++; | 700 | pos++; |
713 | if (s == userid) | 701 | if (s == userid) |
714 | break; | 702 | break; |
715 | |||
716 | } | 703 | } |
717 | } | 704 | } |
718 | } | 705 | } |
@@ -735,7 +722,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice | |||
735 | </body> | 722 | </body> |
736 | </level0> | 723 | </level0> |
737 | </response>", userid, pos, avatarName); | 724 | </response>", userid, pos, avatarName); |
738 | 725 | ||
739 | response["int_response_code"] = 200; | 726 | response["int_response_code"] = 200; |
740 | return response; | 727 | return response; |
741 | /* | 728 | /* |
@@ -752,13 +739,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice | |||
752 | public Hashtable FreeSwitchConfigHTTPHandler(Hashtable request) | 739 | public Hashtable FreeSwitchConfigHTTPHandler(Hashtable request) |
753 | { | 740 | { |
754 | m_log.DebugFormat("[FreeSwitchVoice] FreeSwitchConfigHTTPHandler called with {0}", (string)request["body"]); | 741 | m_log.DebugFormat("[FreeSwitchVoice] FreeSwitchConfigHTTPHandler called with {0}", (string)request["body"]); |
755 | 742 | ||
756 | Hashtable response = new Hashtable(); | 743 | Hashtable response = new Hashtable(); |
757 | response["str_response_string"] = string.Empty; | 744 | response["str_response_string"] = string.Empty; |
758 | // all the params come as NVPs in the request body | 745 | // all the params come as NVPs in the request body |
759 | Hashtable requestBody = parseRequestBody((string) request["body"]); | 746 | Hashtable requestBody = parseRequestBody((string) request["body"]); |
760 | 747 | ||
761 | // is this a dialplan or directory request | 748 | // is this a dialplan or directory request |
762 | string section = (string) requestBody["section"]; | 749 | string section = (string) requestBody["section"]; |
763 | 750 | ||
764 | if (section == "directory") | 751 | if (section == "directory") |
@@ -767,40 +754,39 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice | |||
767 | response = m_FreeSwitchDialplan.HandleDialplanRequest(m_freeSwitchContext, m_freeSwitchRealm, requestBody); | 754 | response = m_FreeSwitchDialplan.HandleDialplanRequest(m_freeSwitchContext, m_freeSwitchRealm, requestBody); |
768 | else | 755 | else |
769 | m_log.WarnFormat("[FreeSwitchVoice]: section was {0}", section); | 756 | m_log.WarnFormat("[FreeSwitchVoice]: section was {0}", section); |
770 | 757 | ||
771 | // XXX: re-generate dialplan: | 758 | // XXX: re-generate dialplan: |
772 | // - conf == region UUID | 759 | // - conf == region UUID |
773 | // - conf number = region port | 760 | // - conf number = region port |
774 | // -> TODO Initialise(): keep track of regions via events | 761 | // -> TODO Initialise(): keep track of regions via events |
775 | // re-generate accounts for all avatars | 762 | // re-generate accounts for all avatars |
776 | // -> TODO Initialise(): keep track of avatars via events | 763 | // -> TODO Initialise(): keep track of avatars via events |
777 | Regex normalizeEndLines = new Regex(@"\r\n", RegexOptions.Compiled | RegexOptions.Singleline | RegexOptions.Multiline); | 764 | Regex normalizeEndLines = new Regex(@"\r\n", RegexOptions.Compiled | RegexOptions.Singleline | RegexOptions.Multiline); |
778 | 765 | ||
779 | m_log.DebugFormat("[FreeSwitchVoice] FreeSwitchConfigHTTPHandler return {0}",normalizeEndLines.Replace(((string)response["str_response_string"]), "")); | 766 | m_log.DebugFormat("[FreeSwitchVoice] FreeSwitchConfigHTTPHandler return {0}",normalizeEndLines.Replace(((string)response["str_response_string"]), "")); |
780 | return response; | 767 | return response; |
781 | } | 768 | } |
782 | 769 | ||
783 | public Hashtable parseRequestBody(string body) | 770 | public Hashtable parseRequestBody(string body) |
784 | { | 771 | { |
785 | Hashtable bodyParams = new Hashtable(); | 772 | Hashtable bodyParams = new Hashtable(); |
786 | // split string | 773 | // split string |
787 | string [] nvps = body.Split(new Char [] {'&'}); | 774 | string [] nvps = body.Split(new Char [] {'&'}); |
788 | 775 | ||
789 | foreach (string s in nvps) { | 776 | foreach (string s in nvps) |
790 | 777 | { | |
791 | if (s.Trim() != "") | 778 | if (s.Trim() != "") |
792 | { | 779 | { |
793 | string [] nvp = s.Split(new Char [] {'='}); | 780 | string [] nvp = s.Split(new Char [] {'='}); |
794 | bodyParams.Add(HttpUtility.UrlDecode(nvp[0]), HttpUtility.UrlDecode(nvp[1])); | 781 | bodyParams.Add(HttpUtility.UrlDecode(nvp[0]), HttpUtility.UrlDecode(nvp[1])); |
795 | } | 782 | } |
796 | } | 783 | } |
797 | 784 | ||
798 | return bodyParams; | 785 | return bodyParams; |
799 | } | 786 | } |
800 | 787 | ||
801 | private string ChannelUri(Scene scene, LandData land) | 788 | private string ChannelUri(Scene scene, LandData land) |
802 | { | 789 | { |
803 | |||
804 | string channelUri = null; | 790 | string channelUri = null; |
805 | 791 | ||
806 | string landUUID; | 792 | string landUUID; |
@@ -808,12 +794,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice | |||
808 | 794 | ||
809 | // Create parcel voice channel. If no parcel exists, then the voice channel ID is the same | 795 | // Create parcel voice channel. If no parcel exists, then the voice channel ID is the same |
810 | // as the directory ID. Otherwise, it reflects the parcel's ID. | 796 | // as the directory ID. Otherwise, it reflects the parcel's ID. |
811 | 797 | ||
812 | lock (m_ParcelAddress) | 798 | lock (m_ParcelAddress) |
813 | { | 799 | { |
814 | if (m_ParcelAddress.ContainsKey(land.GlobalID.ToString())) | 800 | if (m_ParcelAddress.ContainsKey(land.GlobalID.ToString())) |
815 | { | 801 | { |
816 | m_log.DebugFormat("[FreeSwitchVoice]: parcel id {0}: using sip address {1}", | 802 | m_log.DebugFormat("[FreeSwitchVoice]: parcel id {0}: using sip address {1}", |
817 | land.GlobalID, m_ParcelAddress[land.GlobalID.ToString()]); | 803 | land.GlobalID, m_ParcelAddress[land.GlobalID.ToString()]); |
818 | return m_ParcelAddress[land.GlobalID.ToString()]; | 804 | return m_ParcelAddress[land.GlobalID.ToString()]; |
819 | } | 805 | } |
@@ -823,22 +809,22 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice | |||
823 | { | 809 | { |
824 | landName = String.Format("{0}:{1}", scene.RegionInfo.RegionName, land.Name); | 810 | landName = String.Format("{0}:{1}", scene.RegionInfo.RegionName, land.Name); |
825 | landUUID = land.GlobalID.ToString(); | 811 | landUUID = land.GlobalID.ToString(); |
826 | m_log.DebugFormat("[FreeSwitchVoice]: Region:Parcel \"{0}\": parcel id {1}: using channel name {2}", | 812 | m_log.DebugFormat("[FreeSwitchVoice]: Region:Parcel \"{0}\": parcel id {1}: using channel name {2}", |
827 | landName, land.LocalID, landUUID); | 813 | landName, land.LocalID, landUUID); |
828 | } | 814 | } |
829 | else | 815 | else |
830 | { | 816 | { |
831 | landName = String.Format("{0}:{1}", scene.RegionInfo.RegionName, scene.RegionInfo.RegionName); | 817 | landName = String.Format("{0}:{1}", scene.RegionInfo.RegionName, scene.RegionInfo.RegionName); |
832 | landUUID = scene.RegionInfo.RegionID.ToString(); | 818 | landUUID = scene.RegionInfo.RegionID.ToString(); |
833 | m_log.DebugFormat("[FreeSwitchVoice]: Region:Parcel \"{0}\": parcel id {1}: using channel name {2}", | 819 | m_log.DebugFormat("[FreeSwitchVoice]: Region:Parcel \"{0}\": parcel id {1}: using channel name {2}", |
834 | landName, land.LocalID, landUUID); | 820 | landName, land.LocalID, landUUID); |
835 | } | 821 | } |
836 | System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding(); | 822 | System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding(); |
837 | 823 | ||
838 | // slvoice handles the sip address differently if it begins with confctl, hiding it from the user in the friends list. however it also disables | 824 | // slvoice handles the sip address differently if it begins with confctl, hiding it from the user in the friends list. however it also disables |
839 | // the personal speech indicators as well unless some siren14-3d codec magic happens. we dont have siren143d so we'll settle for the personal speech indicator. | 825 | // the personal speech indicators as well unless some siren14-3d codec magic happens. we dont have siren143d so we'll settle for the personal speech indicator. |
840 | channelUri = String.Format("sip:conf-{0}@{1}", "x" + Convert.ToBase64String(encoding.GetBytes(landUUID)), m_freeSwitchRealm); | 826 | channelUri = String.Format("sip:conf-{0}@{1}", "x" + Convert.ToBase64String(encoding.GetBytes(landUUID)), m_freeSwitchRealm); |
841 | 827 | ||
842 | lock (m_ParcelAddress) | 828 | lock (m_ParcelAddress) |
843 | { | 829 | { |
844 | if (!m_ParcelAddress.ContainsKey(land.GlobalID.ToString())) | 830 | if (!m_ParcelAddress.ContainsKey(land.GlobalID.ToString())) |
@@ -849,14 +835,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice | |||
849 | 835 | ||
850 | return channelUri; | 836 | return channelUri; |
851 | } | 837 | } |
852 | 838 | ||
853 | private static bool CustomCertificateValidation(object sender, X509Certificate cert, X509Chain chain, SslPolicyErrors error) | 839 | private static bool CustomCertificateValidation(object sender, X509Certificate cert, X509Chain chain, SslPolicyErrors error) |
854 | { | 840 | { |
855 | |||
856 | return true; | 841 | return true; |
857 | |||
858 | } | 842 | } |
859 | } | 843 | } |
844 | |||
860 | public class MonoCert : ICertificatePolicy | 845 | public class MonoCert : ICertificatePolicy |
861 | { | 846 | { |
862 | #region ICertificatePolicy Members | 847 | #region ICertificatePolicy Members |
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IAvatar.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IAvatar.cs index 03c1e95..3d49732 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IAvatar.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IAvatar.cs | |||
@@ -34,6 +34,9 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | |||
34 | { | 34 | { |
35 | public interface IAvatar : IEntity | 35 | public interface IAvatar : IEntity |
36 | { | 36 | { |
37 | |||
38 | bool IsChildAgent { get; } | ||
39 | |||
37 | //// <value> | 40 | //// <value> |
38 | /// Array of worn attachments, empty but not null, if no attachments are worn | 41 | /// Array of worn attachments, empty but not null, if no attachments are worn |
39 | /// </value> | 42 | /// </value> |
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs index 4427426..0786bd9 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs | |||
@@ -70,6 +70,11 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | |||
70 | set { GetSP().TeleportWithMomentum(value); } | 70 | set { GetSP().TeleportWithMomentum(value); } |
71 | } | 71 | } |
72 | 72 | ||
73 | public bool IsChildAgent | ||
74 | { | ||
75 | get { return GetSP().IsChildAgent; } | ||
76 | } | ||
77 | |||
73 | #region IAvatar implementation | 78 | #region IAvatar implementation |
74 | public IAvatarAttachment[] Attachments | 79 | public IAvatarAttachment[] Attachments |
75 | { | 80 | { |
diff --git a/OpenSim/Region/OptionalModules/SvnSerialiser/SvnBackupModule.cs b/OpenSim/Region/OptionalModules/SvnSerialiser/SvnBackupModule.cs index 3490a8b..ccdea14 100644 --- a/OpenSim/Region/OptionalModules/SvnSerialiser/SvnBackupModule.cs +++ b/OpenSim/Region/OptionalModules/SvnSerialiser/SvnBackupModule.cs | |||
@@ -121,19 +121,19 @@ namespace OpenSim.Region.Modules.SvnSerialiser | |||
121 | { | 121 | { |
122 | serialiser.LoadPrimsFromXml2( | 122 | serialiser.LoadPrimsFromXml2( |
123 | scene, | 123 | scene, |
124 | m_svndir + Slash.DirectorySeparatorChar + scene.RegionInfo.RegionID | 124 | m_svndir + Slash.DirectorySeparatorChar + scene.RegionInfo.RegionID |
125 | + Slash.DirectorySeparatorChar + "objects.xml"); | 125 | + Slash.DirectorySeparatorChar + "objects.xml"); |
126 | 126 | ||
127 | scene.RequestModuleInterface<ITerrainModule>().LoadFromFile( | 127 | scene.RequestModuleInterface<ITerrainModule>().LoadFromFile( |
128 | m_svndir + Slash.DirectorySeparatorChar + scene.RegionInfo.RegionID | 128 | m_svndir + Slash.DirectorySeparatorChar + scene.RegionInfo.RegionID |
129 | + Slash.DirectorySeparatorChar + "heightmap.r32"); | 129 | + Slash.DirectorySeparatorChar + "heightmap.r32"); |
130 | 130 | ||
131 | m_log.Info("[SVNBACKUP]: Region load successful (" + scene.RegionInfo.RegionName + ")."); | 131 | m_log.Info("[SVNBACKUP]: Region load successful (" + scene.RegionInfo.RegionName + ")."); |
132 | } | 132 | } |
133 | else | 133 | else |
134 | { | 134 | { |
135 | m_log.ErrorFormat( | 135 | m_log.ErrorFormat( |
136 | "[SVNBACKUP]: Region load of {0} failed - no serialisation module available", | 136 | "[SVNBACKUP]: Region load of {0} failed - no serialisation module available", |
137 | scene.RegionInfo.RegionName); | 137 | scene.RegionInfo.RegionName); |
138 | } | 138 | } |
139 | } | 139 | } |
diff --git a/OpenSim/Region/Physics/OdePlugin/ODEDynamics.cs b/OpenSim/Region/Physics/OdePlugin/ODEDynamics.cs index 6ae0c8a..9beeabb 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODEDynamics.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODEDynamics.cs | |||
@@ -72,23 +72,23 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
72 | 72 | ||
73 | 73 | ||
74 | // Vehicle properties | 74 | // Vehicle properties |
75 | private Vehicle m_type = Vehicle.TYPE_NONE; // If a 'VEHICLE', and what kind | 75 | private Vehicle m_type = Vehicle.TYPE_NONE; // If a 'VEHICLE', and what kind |
76 | // private Quaternion m_referenceFrame = Quaternion.Identity; // Axis modifier | 76 | // private Quaternion m_referenceFrame = Quaternion.Identity; // Axis modifier |
77 | private VehicleFlag m_flags = (VehicleFlag) 0; // Boolean settings: | 77 | private VehicleFlag m_flags = (VehicleFlag) 0; // Boolean settings: |
78 | // HOVER_TERRAIN_ONLY | 78 | // HOVER_TERRAIN_ONLY |
79 | // HOVER_GLOBAL_HEIGHT | 79 | // HOVER_GLOBAL_HEIGHT |
80 | // NO_DEFLECTION_UP | 80 | // NO_DEFLECTION_UP |
81 | // HOVER_WATER_ONLY | 81 | // HOVER_WATER_ONLY |
82 | // HOVER_UP_ONLY | 82 | // HOVER_UP_ONLY |
83 | // LIMIT_MOTOR_UP | 83 | // LIMIT_MOTOR_UP |
84 | // LIMIT_ROLL_ONLY | 84 | // LIMIT_ROLL_ONLY |
85 | private VehicleFlag m_Hoverflags = (VehicleFlag)0; | 85 | private VehicleFlag m_Hoverflags = (VehicleFlag)0; |
86 | private Vector3 m_BlockingEndPoint = Vector3.Zero; | 86 | private Vector3 m_BlockingEndPoint = Vector3.Zero; |
87 | private Quaternion m_RollreferenceFrame = Quaternion.Identity; | 87 | private Quaternion m_RollreferenceFrame = Quaternion.Identity; |
88 | // Linear properties | 88 | // Linear properties |
89 | private Vector3 m_linearMotorDirection = Vector3.Zero; // velocity requested by LSL, decayed by time | 89 | private Vector3 m_linearMotorDirection = Vector3.Zero; // velocity requested by LSL, decayed by time |
90 | private Vector3 m_linearMotorDirectionLASTSET = Vector3.Zero; // velocity requested by LSL | 90 | private Vector3 m_linearMotorDirectionLASTSET = Vector3.Zero; // velocity requested by LSL |
91 | private Vector3 m_dir = Vector3.Zero; // velocity applied to body | 91 | private Vector3 m_dir = Vector3.Zero; // velocity applied to body |
92 | private Vector3 m_linearFrictionTimescale = Vector3.Zero; | 92 | private Vector3 m_linearFrictionTimescale = Vector3.Zero; |
93 | private float m_linearMotorDecayTimescale = 0; | 93 | private float m_linearMotorDecayTimescale = 0; |
94 | private float m_linearMotorTimescale = 0; | 94 | private float m_linearMotorTimescale = 0; |
@@ -98,14 +98,14 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
98 | // private Vector3 m_linearMotorOffset = Vector3.Zero; | 98 | // private Vector3 m_linearMotorOffset = Vector3.Zero; |
99 | 99 | ||
100 | //Angular properties | 100 | //Angular properties |
101 | private Vector3 m_angularMotorDirection = Vector3.Zero; // angular velocity requested by LSL motor | 101 | private Vector3 m_angularMotorDirection = Vector3.Zero; // angular velocity requested by LSL motor |
102 | private int m_angularMotorApply = 0; // application frame counter | 102 | private int m_angularMotorApply = 0; // application frame counter |
103 | private Vector3 m_angularMotorVelocity = Vector3.Zero; // current angular motor velocity | 103 | private Vector3 m_angularMotorVelocity = Vector3.Zero; // current angular motor velocity |
104 | private float m_angularMotorTimescale = 0; // motor angular velocity ramp up rate | 104 | private float m_angularMotorTimescale = 0; // motor angular velocity ramp up rate |
105 | private float m_angularMotorDecayTimescale = 0; // motor angular velocity decay rate | 105 | private float m_angularMotorDecayTimescale = 0; // motor angular velocity decay rate |
106 | private Vector3 m_angularFrictionTimescale = Vector3.Zero; // body angular velocity decay rate | 106 | private Vector3 m_angularFrictionTimescale = Vector3.Zero; // body angular velocity decay rate |
107 | private Vector3 m_lastAngularVelocity = Vector3.Zero; // what was last applied to body | 107 | private Vector3 m_lastAngularVelocity = Vector3.Zero; // what was last applied to body |
108 | // private Vector3 m_lastVertAttractor = Vector3.Zero; // what VA was last applied to body | 108 | // private Vector3 m_lastVertAttractor = Vector3.Zero; // what VA was last applied to body |
109 | 109 | ||
110 | //Deflection properties | 110 | //Deflection properties |
111 | // private float m_angularDeflectionEfficiency = 0; | 111 | // private float m_angularDeflectionEfficiency = 0; |
@@ -123,14 +123,14 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
123 | // private float m_VhoverEfficiency = 0f; | 123 | // private float m_VhoverEfficiency = 0f; |
124 | private float m_VhoverTimescale = 0f; | 124 | private float m_VhoverTimescale = 0f; |
125 | private float m_VhoverTargetHeight = -1.0f; // if <0 then no hover, else its the current target height | 125 | private float m_VhoverTargetHeight = -1.0f; // if <0 then no hover, else its the current target height |
126 | private float m_VehicleBuoyancy = 0f; //KF: m_VehicleBuoyancy is set by VEHICLE_BUOYANCY for a vehicle. | 126 | private float m_VehicleBuoyancy = 0f; //KF: m_VehicleBuoyancy is set by VEHICLE_BUOYANCY for a vehicle. |
127 | // Modifies gravity. Slider between -1 (double-gravity) and 1 (full anti-gravity) | 127 | // Modifies gravity. Slider between -1 (double-gravity) and 1 (full anti-gravity) |
128 | // KF: So far I have found no good method to combine a script-requested .Z velocity and gravity. | 128 | // KF: So far I have found no good method to combine a script-requested .Z velocity and gravity. |
129 | // Therefore only m_VehicleBuoyancy=1 (0g) will use the script-requested .Z velocity. | 129 | // Therefore only m_VehicleBuoyancy=1 (0g) will use the script-requested .Z velocity. |
130 | 130 | ||
131 | //Attractor properties | 131 | //Attractor properties |
132 | private float m_verticalAttractionEfficiency = 1.0f; // damped | 132 | private float m_verticalAttractionEfficiency = 1.0f; // damped |
133 | private float m_verticalAttractionTimescale = 500f; // Timescale > 300 means no vert attractor. | 133 | private float m_verticalAttractionTimescale = 500f; // Timescale > 300 means no vert attractor. |
134 | 134 | ||
135 | internal void ProcessFloatVehicleParam(Vehicle pParam, float pValue) | 135 | internal void ProcessFloatVehicleParam(Vehicle pParam, float pValue) |
136 | { | 136 | { |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index a421484..dc4249c 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -8192,38 +8192,38 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8192 | { | 8192 | { |
8193 | m_host.AddScriptLPS(1); | 8193 | m_host.AddScriptLPS(1); |
8194 | if (m_ScriptEngine.Config.GetBoolean("AllowGodFunctions", false)) | 8194 | if (m_ScriptEngine.Config.GetBoolean("AllowGodFunctions", false)) |
8195 | { | 8195 | { |
8196 | if (World.Permissions.CanRunConsoleCommand(m_host.OwnerID)) | 8196 | if (World.Permissions.CanRunConsoleCommand(m_host.OwnerID)) |
8197 | { | 8197 | { |
8198 | lock (m_host.TaskInventory) | 8198 | lock (m_host.TaskInventory) |
8199 | { | 8199 | { |
8200 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 8200 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) |
8201 | { | 8201 | { |
8202 | if (inv.Value.Name == item) | 8202 | if (inv.Value.Name == item) |
8203 | { | 8203 | { |
8204 | switch (mask) | 8204 | switch (mask) |
8205 | { | 8205 | { |
8206 | case 0: | 8206 | case 0: |
8207 | inv.Value.BasePermissions = (uint)value; | 8207 | inv.Value.BasePermissions = (uint)value; |
8208 | break; | 8208 | break; |
8209 | case 1: | 8209 | case 1: |
8210 | inv.Value.CurrentPermissions = (uint)value; | 8210 | inv.Value.CurrentPermissions = (uint)value; |
8211 | break; | 8211 | break; |
8212 | case 2: | 8212 | case 2: |
8213 | inv.Value.GroupPermissions = (uint)value; | 8213 | inv.Value.GroupPermissions = (uint)value; |
8214 | break; | 8214 | break; |
8215 | case 3: | 8215 | case 3: |
8216 | inv.Value.EveryonePermissions = (uint)value; | 8216 | inv.Value.EveryonePermissions = (uint)value; |
8217 | break; | 8217 | break; |
8218 | case 4: | 8218 | case 4: |
8219 | inv.Value.NextPermissions = (uint)value; | 8219 | inv.Value.NextPermissions = (uint)value; |
8220 | break; | 8220 | break; |
8221 | } | 8221 | } |
8222 | } | 8222 | } |
8223 | } | 8223 | } |
8224 | } | 8224 | } |
8225 | } | 8225 | } |
8226 | } | 8226 | } |
8227 | } | 8227 | } |
8228 | 8228 | ||
8229 | public LSL_String llGetInventoryCreator(string item) | 8229 | public LSL_String llGetInventoryCreator(string item) |
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index c552b92..98e77c0 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | |||
@@ -841,7 +841,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
841 | ObjectRemoved handlerObjectRemoved = OnObjectRemoved; | 841 | ObjectRemoved handlerObjectRemoved = OnObjectRemoved; |
842 | if (handlerObjectRemoved != null) | 842 | if (handlerObjectRemoved != null) |
843 | { | 843 | { |
844 | SceneObjectPart part = m_Scene.GetSceneObjectPart(localID); | 844 | SceneObjectPart part = m_Scene.GetSceneObjectPart(localID); |
845 | handlerObjectRemoved(part.UUID); | 845 | handlerObjectRemoved(part.UUID); |
846 | } | 846 | } |
847 | 847 | ||
diff --git a/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs b/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs index a944972..3ab1622 100644 --- a/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs +++ b/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs | |||
@@ -207,7 +207,7 @@ namespace OpenSim.Server.Handlers.Asset | |||
207 | if (!request.ContainsKey("PRINCIPAL")) | 207 | if (!request.ContainsKey("PRINCIPAL")) |
208 | return FailureResult(); | 208 | return FailureResult(); |
209 | 209 | ||
210 | if(m_InventoryService.CreateUserInventory(new UUID(request["PRINCIPAL"].ToString()))) | 210 | if (m_InventoryService.CreateUserInventory(new UUID(request["PRINCIPAL"].ToString()))) |
211 | result["RESULT"] = "True"; | 211 | result["RESULT"] = "True"; |
212 | else | 212 | else |
213 | result["RESULT"] = "False"; | 213 | result["RESULT"] = "False"; |
diff --git a/OpenSim/Services/AssetService/AssetService.cs b/OpenSim/Services/AssetService/AssetService.cs index a91b632..b9723a8 100644 --- a/OpenSim/Services/AssetService/AssetService.cs +++ b/OpenSim/Services/AssetService/AssetService.cs | |||
@@ -81,12 +81,12 @@ namespace OpenSim.Services.AssetService | |||
81 | } | 81 | } |
82 | 82 | ||
83 | public AssetBase Get(string id) | 83 | public AssetBase Get(string id) |
84 | { | 84 | { |
85 | UUID assetID; | 85 | UUID assetID; |
86 | 86 | ||
87 | if (!UUID.TryParse(id, out assetID)) | 87 | if (!UUID.TryParse(id, out assetID)) |
88 | { | 88 | { |
89 | m_log.WarnFormat("[ASSET SERVICE]: Could not parse requested sset id {0}", id); | 89 | m_log.WarnFormat("[ASSET SERVICE]: Could not parse requested sset id {0}", id); |
90 | return null; | 90 | return null; |
91 | } | 91 | } |
92 | 92 | ||
diff --git a/OpenSim/Services/AuthenticationService/AuthenticationServiceBase.cs b/OpenSim/Services/AuthenticationService/AuthenticationServiceBase.cs index f6dd085..9af61a9 100644 --- a/OpenSim/Services/AuthenticationService/AuthenticationServiceBase.cs +++ b/OpenSim/Services/AuthenticationService/AuthenticationServiceBase.cs | |||
@@ -106,12 +106,17 @@ namespace OpenSim.Services.AuthenticationService | |||
106 | string passwordSalt = Util.Md5Hash(UUID.Random().ToString()); | 106 | string passwordSalt = Util.Md5Hash(UUID.Random().ToString()); |
107 | string md5PasswdHash = Util.Md5Hash(Util.Md5Hash(password) + ":" + passwordSalt); | 107 | string md5PasswdHash = Util.Md5Hash(Util.Md5Hash(password) + ":" + passwordSalt); |
108 | 108 | ||
109 | AuthenticationData auth = new AuthenticationData(); | 109 | AuthenticationData auth = m_Database.Get(principalID); |
110 | auth.PrincipalID = principalID; | 110 | if (auth == null) |
111 | auth.Data = new System.Collections.Generic.Dictionary<string, object>(); | 111 | { |
112 | auth = new AuthenticationData(); | ||
113 | auth.PrincipalID = principalID; | ||
114 | auth.Data = new System.Collections.Generic.Dictionary<string, object>(); | ||
115 | auth.Data["accountType"] = "UserAccount"; | ||
116 | auth.Data["webLoginKey"] = UUID.Zero.ToString(); | ||
117 | } | ||
112 | auth.Data["passwordHash"] = md5PasswdHash; | 118 | auth.Data["passwordHash"] = md5PasswdHash; |
113 | auth.Data["passwordSalt"] = passwordSalt; | 119 | auth.Data["passwordSalt"] = passwordSalt; |
114 | auth.Data["webLoginKey"] = UUID.Zero.ToString(); | ||
115 | if (!m_Database.Store(auth)) | 120 | if (!m_Database.Store(auth)) |
116 | { | 121 | { |
117 | m_log.DebugFormat("[AUTHENTICATION DB]: Failed to store authentication data"); | 122 | m_log.DebugFormat("[AUTHENTICATION DB]: Failed to store authentication data"); |
diff --git a/OpenSim/Services/Base/ServiceBase.cs b/OpenSim/Services/Base/ServiceBase.cs index 6bbe978..8e24d85 100644 --- a/OpenSim/Services/Base/ServiceBase.cs +++ b/OpenSim/Services/Base/ServiceBase.cs | |||
@@ -64,7 +64,7 @@ namespace OpenSim.Services.Base | |||
64 | foreach (Type pluginType in pluginAssembly.GetTypes()) | 64 | foreach (Type pluginType in pluginAssembly.GetTypes()) |
65 | { | 65 | { |
66 | if (pluginType.IsPublic) | 66 | if (pluginType.IsPublic) |
67 | { | 67 | { |
68 | if (className != String.Empty && | 68 | if (className != String.Empty && |
69 | pluginType.ToString() != | 69 | pluginType.ToString() != |
70 | pluginType.Namespace + "." + className) | 70 | pluginType.Namespace + "." + className) |
@@ -84,8 +84,9 @@ namespace OpenSim.Services.Base | |||
84 | 84 | ||
85 | return null; | 85 | return null; |
86 | } | 86 | } |
87 | catch (Exception) | 87 | catch (Exception e) |
88 | { | 88 | { |
89 | Console.WriteLine("XXX Exception " + e.StackTrace); | ||
89 | return null; | 90 | return null; |
90 | } | 91 | } |
91 | } | 92 | } |
diff --git a/OpenSim/Services/Connectors/Asset/AssetServiceConnector.cs b/OpenSim/Services/Connectors/Asset/AssetServiceConnector.cs index 876e7ed..966af0b 100644 --- a/OpenSim/Services/Connectors/Asset/AssetServiceConnector.cs +++ b/OpenSim/Services/Connectors/Asset/AssetServiceConnector.cs | |||
@@ -93,7 +93,7 @@ namespace OpenSim.Services.Connectors | |||
93 | } | 93 | } |
94 | 94 | ||
95 | public AssetBase Get(string id) | 95 | public AssetBase Get(string id) |
96 | { | 96 | { |
97 | string uri = m_ServerURI + "/assets/" + id; | 97 | string uri = m_ServerURI + "/assets/" + id; |
98 | 98 | ||
99 | AssetBase asset = null; | 99 | AssetBase asset = null; |
diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index 4dee7a4..1368e46 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs | |||
@@ -82,20 +82,22 @@ namespace OpenSim.Services.GridService | |||
82 | { | 82 | { |
83 | m_RootInstance = this; | 83 | m_RootInstance = this; |
84 | 84 | ||
85 | MainConsole.Instance.Commands.AddCommand("grid", true, | 85 | if (MainConsole.Instance != null) |
86 | "show region", | 86 | { |
87 | "show region <Region name>", | 87 | MainConsole.Instance.Commands.AddCommand("grid", true, |
88 | "Show details on a region", | 88 | "show region", |
89 | String.Empty, | 89 | "show region <Region name>", |
90 | HandleShowRegion); | 90 | "Show details on a region", |
91 | 91 | String.Empty, | |
92 | MainConsole.Instance.Commands.AddCommand("grid", true, | 92 | HandleShowRegion); |
93 | "set region flags", | 93 | |
94 | "set region flags <Region name> <flags>", | 94 | MainConsole.Instance.Commands.AddCommand("grid", true, |
95 | "Set database flags for region", | 95 | "set region flags", |
96 | String.Empty, | 96 | "set region flags <Region name> <flags>", |
97 | HandleSetFlags); | 97 | "Set database flags for region", |
98 | 98 | String.Empty, | |
99 | HandleSetFlags); | ||
100 | } | ||
99 | m_HypergridLinker = new HypergridLinker(m_config, this, m_Database); | 101 | m_HypergridLinker = new HypergridLinker(m_config, this, m_Database); |
100 | } | 102 | } |
101 | } | 103 | } |
diff --git a/OpenSim/Services/GridService/HypergridLinker.cs b/OpenSim/Services/GridService/HypergridLinker.cs index 18d0586..de5df9d 100644 --- a/OpenSim/Services/GridService/HypergridLinker.cs +++ b/OpenSim/Services/GridService/HypergridLinker.cs | |||
@@ -113,18 +113,20 @@ namespace OpenSim.Services.GridService | |||
113 | 113 | ||
114 | m_log.DebugFormat("[HYPERGRID LINKER]: Loaded all services..."); | 114 | m_log.DebugFormat("[HYPERGRID LINKER]: Loaded all services..."); |
115 | } | 115 | } |
116 | 116 | ||
117 | 117 | if (MainConsole.Instance != null) | |
118 | MainConsole.Instance.Commands.AddCommand("hypergrid", false, "link-region", | 118 | { |
119 | "link-region <Xloc> <Yloc> <HostName>:<HttpPort>[:<RemoteRegionName>] <cr>", | 119 | MainConsole.Instance.Commands.AddCommand("hypergrid", false, "link-region", |
120 | "Link a hypergrid region", RunCommand); | 120 | "link-region <Xloc> <Yloc> <HostName>:<HttpPort>[:<RemoteRegionName>] <cr>", |
121 | MainConsole.Instance.Commands.AddCommand("hypergrid", false, "unlink-region", | 121 | "Link a hypergrid region", RunCommand); |
122 | "unlink-region <local name> or <HostName>:<HttpPort> <cr>", | 122 | MainConsole.Instance.Commands.AddCommand("hypergrid", false, "unlink-region", |
123 | "Unlink a hypergrid region", RunCommand); | 123 | "unlink-region <local name> or <HostName>:<HttpPort> <cr>", |
124 | MainConsole.Instance.Commands.AddCommand("hypergrid", false, "link-mapping", "link-mapping [<x> <y>] <cr>", | 124 | "Unlink a hypergrid region", RunCommand); |
125 | "Set local coordinate to map HG regions to", RunCommand); | 125 | MainConsole.Instance.Commands.AddCommand("hypergrid", false, "link-mapping", "link-mapping [<x> <y>] <cr>", |
126 | MainConsole.Instance.Commands.AddCommand("hypergrid", false, "show hyperlinks", "show hyperlinks <cr>", | 126 | "Set local coordinate to map HG regions to", RunCommand); |
127 | "List the HG regions", HandleShow); | 127 | MainConsole.Instance.Commands.AddCommand("hypergrid", false, "show hyperlinks", "show hyperlinks <cr>", |
128 | "List the HG regions", HandleShow); | ||
129 | } | ||
128 | } | 130 | } |
129 | 131 | ||
130 | 132 | ||
diff --git a/OpenSim/Services/UserAccountService/UserAccountService.cs b/OpenSim/Services/UserAccountService/UserAccountService.cs index ffb9cca..e498bd5 100644 --- a/OpenSim/Services/UserAccountService/UserAccountService.cs +++ b/OpenSim/Services/UserAccountService/UserAccountService.cs | |||
@@ -77,13 +77,16 @@ namespace OpenSim.Services.UserAccountService | |||
77 | if (invServiceDll != string.Empty) | 77 | if (invServiceDll != string.Empty) |
78 | m_InventoryService = LoadPlugin<IInventoryService>(invServiceDll, new Object[] { config }); | 78 | m_InventoryService = LoadPlugin<IInventoryService>(invServiceDll, new Object[] { config }); |
79 | 79 | ||
80 | MainConsole.Instance.Commands.AddCommand("UserService", false, | 80 | if (MainConsole.Instance != null) |
81 | "create user", | 81 | { |
82 | "create user [<first> [<last> [<pass> [<email>]]]]", | 82 | MainConsole.Instance.Commands.AddCommand("UserService", false, |
83 | "Create a new user", HandleCreateUser); | 83 | "create user", |
84 | MainConsole.Instance.Commands.AddCommand("UserService", false, "reset user password", | 84 | "create user [<first> [<last> [<pass> [<email>]]]]", |
85 | "reset user password [<first> [<last> [<password>]]]", | 85 | "Create a new user", HandleCreateUser); |
86 | "Reset a user password", HandleResetUserPassword); | 86 | MainConsole.Instance.Commands.AddCommand("UserService", false, "reset user password", |
87 | "reset user password [<first> [<last> [<password>]]]", | ||
88 | "Reset a user password", HandleResetUserPassword); | ||
89 | } | ||
87 | 90 | ||
88 | } | 91 | } |
89 | 92 | ||
diff --git a/OpenSim/Tests/Common/Mock/TestUserDataPlugin.cs b/OpenSim/Tests/Common/Mock/TestUserDataPlugin.cs deleted file mode 100644 index 5188cf6..0000000 --- a/OpenSim/Tests/Common/Mock/TestUserDataPlugin.cs +++ /dev/null | |||
@@ -1,216 +0,0 @@ | |||
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 OpenMetaverse; | ||
31 | using OpenSim.Framework; | ||
32 | using OpenSim.Data; | ||
33 | |||
34 | namespace OpenSim.Tests.Common.Mock | ||
35 | { | ||
36 | /// <summary> | ||
37 | /// In memory user data provider. Might be quite useful as a proper user data plugin, though getting mono addins | ||
38 | /// to load any plugins when running unit tests has proven impossible so far. Currently no locking since unit | ||
39 | /// tests are single threaded. | ||
40 | /// </summary> | ||
41 | public class TestUserDataPlugin : IUserDataPlugin | ||
42 | { | ||
43 | public string Version { get { return "0"; } } | ||
44 | public string Name { get { return "TestUserDataPlugin"; } } | ||
45 | |||
46 | /// <summary> | ||
47 | /// User profiles keyed by name | ||
48 | /// </summary> | ||
49 | private Dictionary<string, UserProfileData> m_userProfilesByName = new Dictionary<string, UserProfileData>(); | ||
50 | |||
51 | /// <summary> | ||
52 | /// User profiles keyed by uuid | ||
53 | /// </summary> | ||
54 | private Dictionary<UUID, UserProfileData> m_userProfilesByUuid = new Dictionary<UUID, UserProfileData>(); | ||
55 | |||
56 | /// <summary> | ||
57 | /// User profiles and their agents | ||
58 | /// </summary> | ||
59 | private Dictionary<UUID, UserAgentData> m_agentByProfileUuid = new Dictionary<UUID, UserAgentData>(); | ||
60 | |||
61 | /// <summary> | ||
62 | /// Friends list by uuid | ||
63 | /// </summary> | ||
64 | private Dictionary<UUID, List<FriendListItem>> m_friendsListByUuid = new Dictionary<UUID, List<FriendListItem>>(); | ||
65 | |||
66 | public void Initialise() {} | ||
67 | public void Dispose() {} | ||
68 | |||
69 | public void AddTemporaryUserProfile(UserProfileData userProfile) | ||
70 | { | ||
71 | // Not interested | ||
72 | } | ||
73 | |||
74 | public void AddNewUserProfile(UserProfileData user) | ||
75 | { | ||
76 | UpdateUserProfile(user); | ||
77 | } | ||
78 | |||
79 | public UserProfileData GetUserByUUID(UUID user) | ||
80 | { | ||
81 | UserProfileData userProfile = null; | ||
82 | m_userProfilesByUuid.TryGetValue(user, out userProfile); | ||
83 | |||
84 | return userProfile; | ||
85 | } | ||
86 | |||
87 | public UserProfileData GetUserByName(string fname, string lname) | ||
88 | { | ||
89 | UserProfileData userProfile = null; | ||
90 | m_userProfilesByName.TryGetValue(fname + " " + lname, out userProfile); | ||
91 | |||
92 | return userProfile; | ||
93 | } | ||
94 | |||
95 | public UserProfileData GetUserByUri(Uri uri) { return null; } | ||
96 | |||
97 | public bool UpdateUserProfile(UserProfileData user) | ||
98 | { | ||
99 | m_userProfilesByUuid[user.ID] = user; | ||
100 | m_userProfilesByName[user.FirstName + " " + user.SurName] = user; | ||
101 | |||
102 | return true; | ||
103 | } | ||
104 | |||
105 | public List<AvatarPickerAvatar> GeneratePickerResults(UUID queryID, string query) { return null; } | ||
106 | |||
107 | public UserAgentData GetAgentByUUID(UUID user) | ||
108 | { | ||
109 | UserAgentData userAgent = null; | ||
110 | m_agentByProfileUuid.TryGetValue(user, out userAgent); | ||
111 | |||
112 | return userAgent; | ||
113 | } | ||
114 | |||
115 | public UserAgentData GetAgentByName(string name) | ||
116 | { | ||
117 | UserProfileData userProfile = null; | ||
118 | m_userProfilesByName.TryGetValue(name, out userProfile); | ||
119 | UserAgentData userAgent = null; | ||
120 | m_agentByProfileUuid.TryGetValue(userProfile.ID, out userAgent); | ||
121 | |||
122 | return userAgent; | ||
123 | } | ||
124 | |||
125 | public UserAgentData GetAgentByName(string fname, string lname) | ||
126 | { | ||
127 | UserProfileData userProfile = GetUserByName(fname,lname); | ||
128 | UserAgentData userAgent = null; | ||
129 | m_agentByProfileUuid.TryGetValue(userProfile.ID, out userAgent); | ||
130 | |||
131 | return userAgent; | ||
132 | } | ||
133 | |||
134 | public void StoreWebLoginKey(UUID agentID, UUID webLoginKey) {} | ||
135 | |||
136 | public void AddNewUserAgent(UserAgentData agent) | ||
137 | { | ||
138 | m_agentByProfileUuid[agent.ProfileID] = agent; | ||
139 | } | ||
140 | public void AddNewUserFriend(UUID friendlistowner, UUID friend, uint perms) | ||
141 | { | ||
142 | FriendListItem newfriend = new FriendListItem(); | ||
143 | newfriend.FriendPerms = perms; | ||
144 | newfriend.Friend = friend; | ||
145 | newfriend.FriendListOwner = friendlistowner; | ||
146 | |||
147 | if (!m_friendsListByUuid.ContainsKey(friendlistowner)) | ||
148 | { | ||
149 | List<FriendListItem> friendslist = new List<FriendListItem>(); | ||
150 | m_friendsListByUuid[friendlistowner] = friendslist; | ||
151 | |||
152 | } | ||
153 | m_friendsListByUuid[friendlistowner].Add(newfriend); | ||
154 | } | ||
155 | |||
156 | public void RemoveUserFriend(UUID friendlistowner, UUID friend) | ||
157 | { | ||
158 | if (m_friendsListByUuid.ContainsKey(friendlistowner)) | ||
159 | { | ||
160 | List<FriendListItem> friendslist = m_friendsListByUuid[friendlistowner]; | ||
161 | foreach (FriendListItem frienditem in friendslist) | ||
162 | { | ||
163 | if (frienditem.Friend == friend) | ||
164 | { | ||
165 | friendslist.Remove(frienditem); | ||
166 | break; | ||
167 | } | ||
168 | } | ||
169 | } | ||
170 | } | ||
171 | |||
172 | public void UpdateUserFriendPerms(UUID friendlistowner, UUID friend, uint perms) | ||
173 | { | ||
174 | if (m_friendsListByUuid.ContainsKey(friendlistowner)) | ||
175 | { | ||
176 | List<FriendListItem> friendslist = m_friendsListByUuid[friendlistowner]; | ||
177 | foreach (FriendListItem frienditem in friendslist) | ||
178 | { | ||
179 | if (frienditem.Friend == friend) | ||
180 | { | ||
181 | frienditem.FriendPerms = perms; | ||
182 | break; | ||
183 | } | ||
184 | } | ||
185 | } | ||
186 | } | ||
187 | |||
188 | public List<FriendListItem> GetUserFriendList(UUID friendlistowner) | ||
189 | { | ||
190 | if (m_friendsListByUuid.ContainsKey(friendlistowner)) | ||
191 | { | ||
192 | return m_friendsListByUuid[friendlistowner]; | ||
193 | } | ||
194 | else | ||
195 | return new List<FriendListItem>(); | ||
196 | |||
197 | |||
198 | } | ||
199 | |||
200 | public Dictionary<UUID, FriendRegionInfo> GetFriendRegionInfos(List<UUID> uuids) { return null; } | ||
201 | |||
202 | public bool MoneyTransferRequest(UUID from, UUID to, uint amount) { return false; } | ||
203 | |||
204 | public bool InventoryTransferRequest(UUID from, UUID to, UUID inventory) { return false; } | ||
205 | |||
206 | public void Initialise(string connect) { return; } | ||
207 | |||
208 | public AvatarAppearance GetUserAppearance(UUID user) { return null; } | ||
209 | |||
210 | public void UpdateUserAppearance(UUID user, AvatarAppearance appearance) {} | ||
211 | |||
212 | public void ResetAttachments(UUID userID) {} | ||
213 | |||
214 | public void LogoutUsers(UUID regionID) {} | ||
215 | } | ||
216 | } | ||
diff --git a/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs b/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs index e37e137..9e718f6 100644 --- a/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs +++ b/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs | |||
@@ -45,6 +45,7 @@ using OpenSim.Region.CoreModules.Avatar.Gods; | |||
45 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset; | 45 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset; |
46 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory; | 46 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory; |
47 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid; | 47 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid; |
48 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts; | ||
48 | using OpenSim.Services.Interfaces; | 49 | using OpenSim.Services.Interfaces; |
49 | using OpenSim.Tests.Common.Mock; | 50 | using OpenSim.Tests.Common.Mock; |
50 | 51 | ||
@@ -60,6 +61,7 @@ namespace OpenSim.Tests.Common.Setup | |||
60 | private static ISharedRegionModule m_assetService = null; | 61 | private static ISharedRegionModule m_assetService = null; |
61 | private static ISharedRegionModule m_inventoryService = null; | 62 | private static ISharedRegionModule m_inventoryService = null; |
62 | private static ISharedRegionModule m_gridService = null; | 63 | private static ISharedRegionModule m_gridService = null; |
64 | private static ISharedRegionModule m_userAccountService = null; | ||
63 | 65 | ||
64 | /// <summary> | 66 | /// <summary> |
65 | /// Set up a test scene | 67 | /// Set up a test scene |
@@ -183,6 +185,8 @@ namespace OpenSim.Tests.Common.Setup | |||
183 | StartInventoryService(testScene, false); | 185 | StartInventoryService(testScene, false); |
184 | if (realServices.Contains("grid")) | 186 | if (realServices.Contains("grid")) |
185 | StartGridService(testScene, true); | 187 | StartGridService(testScene, true); |
188 | if (realServices.Contains("useraccounts")) | ||
189 | StartUserAccountService(testScene, true); | ||
186 | 190 | ||
187 | } | 191 | } |
188 | // If not, make sure the shared module gets references to this new scene | 192 | // If not, make sure the shared module gets references to this new scene |
@@ -269,6 +273,28 @@ namespace OpenSim.Tests.Common.Setup | |||
269 | //testScene.AddRegionModule(m_gridService.Name, m_gridService); | 273 | //testScene.AddRegionModule(m_gridService.Name, m_gridService); |
270 | } | 274 | } |
271 | 275 | ||
276 | private static void StartUserAccountService(Scene testScene, bool real) | ||
277 | { | ||
278 | IConfigSource config = new IniConfigSource(); | ||
279 | config.AddConfig("Modules"); | ||
280 | config.AddConfig("UserAccountService"); | ||
281 | config.Configs["Modules"].Set("UserAccountServices", "LocalUserAccountServicesConnector"); | ||
282 | config.Configs["UserAccountService"].Set("StorageProvider", "OpenSim.Data.Null.dll"); | ||
283 | if (real) | ||
284 | config.Configs["UserAccountService"].Set("LocalServiceModule", "OpenSim.Services.UserAccountService.dll:UserAccountService"); | ||
285 | if (m_userAccountService == null) | ||
286 | { | ||
287 | ISharedRegionModule userAccountService = new LocalUserAccountServicesConnector(); | ||
288 | userAccountService.Initialise(config); | ||
289 | m_userAccountService = userAccountService; | ||
290 | } | ||
291 | //else | ||
292 | // config.Configs["GridService"].Set("LocalServiceModule", "OpenSim.Tests.Common.dll:TestGridService"); | ||
293 | m_userAccountService.AddRegion(testScene); | ||
294 | m_userAccountService.RegionLoaded(testScene); | ||
295 | //testScene.AddRegionModule(m_gridService.Name, m_gridService); | ||
296 | } | ||
297 | |||
272 | 298 | ||
273 | /// <summary> | 299 | /// <summary> |
274 | /// Setup modules for a scene using their default settings. | 300 | /// Setup modules for a scene using their default settings. |
diff --git a/bin/OpenSim.Server.ini.example b/bin/OpenSim.Server.ini.example index 0535765..54101b0 100644 --- a/bin/OpenSim.Server.ini.example +++ b/bin/OpenSim.Server.ini.example | |||
@@ -122,17 +122,3 @@ ServiceConnectors = "8003/OpenSim.Server.Handlers.dll:AssetServiceConnector,8003 | |||
122 | LibraryService = "OpenSim.Services.InventoryService.dll:LibraryService" | 122 | LibraryService = "OpenSim.Services.InventoryService.dll:LibraryService" |
123 | 123 | ||
124 | WelcomeMessage = "Welcome, Avatar!" | 124 | WelcomeMessage = "Welcome, Avatar!" |
125 | |||
126 | ; * This is the new style grid service. | ||
127 | ; * "Realm" is the table that is used for user lookup. | ||
128 | ; * It defaults to "regions", which uses the legacy tables | ||
129 | ; * | ||
130 | [GridService] | ||
131 | LocalServiceModule = "OpenSim.Services.GridService.dll:GridService" | ||
132 | StorageProvider = "OpenSim.Data.MySQL.dll:MySqlRegionData" | ||
133 | ConnectionString = "Data Source=localhost;Database=opensim;User ID=opensim;Password=grid;" | ||
134 | Realm = "regions" | ||
135 | |||
136 | ; If true, duplicate region names are allowed on the grid. If false, no duplicate names are allowed | ||
137 | ; Default is false | ||
138 | ; AllowDuplicateNames = "True" | ||
diff --git a/bin/config-include/Standalone.ini b/bin/config-include/Standalone.ini index bd90df4..06333d8 100644 --- a/bin/config-include/Standalone.ini +++ b/bin/config-include/Standalone.ini | |||
@@ -4,9 +4,6 @@ | |||
4 | ;; which you can copy and change. | 4 | ;; which you can copy and change. |
5 | ;; | 5 | ;; |
6 | 6 | ||
7 | [Includes] | ||
8 | Include-Common = "config-include/StandaloneCommon.ini" | ||
9 | |||
10 | [Modules] | 7 | [Modules] |
11 | AssetServices = "LocalAssetServicesConnector" | 8 | AssetServices = "LocalAssetServicesConnector" |
12 | InventoryServices = "LocalInventoryServicesConnector" | 9 | InventoryServices = "LocalInventoryServicesConnector" |
@@ -35,14 +32,14 @@ | |||
35 | 32 | ||
36 | [AvatarService] | 33 | [AvatarService] |
37 | LocalServiceModule = "OpenSim.Services.AvatarService.dll:AvatarService" | 34 | LocalServiceModule = "OpenSim.Services.AvatarService.dll:AvatarService" |
38 | StorageProvider = "OpenSim.Data.Null.dll" | 35 | ConnectionString = "URI=file:avatars.db,version=3" |
39 | 36 | ||
40 | [AuthorizationService] | 37 | [AuthorizationService] |
41 | LocalServiceModule = "OpenSim.Services.AuthorizationService.dll:AuthorizationService" | 38 | LocalServiceModule = "OpenSim.Services.AuthorizationService.dll:AuthorizationService" |
42 | 39 | ||
43 | [AuthenticationService] | 40 | [AuthenticationService] |
44 | LocalServiceModule = "OpenSim.Services.AuthenticationService.dll:PasswordAuthenticationService" | 41 | LocalServiceModule = "OpenSim.Services.AuthenticationService.dll:PasswordAuthenticationService" |
45 | StorageProvider = "OpenSim.Data.Null.dll" | 42 | ConnectionString = "URI=file:auth.db,version=3" |
46 | 43 | ||
47 | [GridService] | 44 | [GridService] |
48 | LocalServiceModule = "OpenSim.Services.GridService.dll:GridService" | 45 | LocalServiceModule = "OpenSim.Services.GridService.dll:GridService" |
@@ -55,7 +52,7 @@ | |||
55 | 52 | ||
56 | [UserAccountService] | 53 | [UserAccountService] |
57 | LocalServiceModule = "OpenSim.Services.UserAccountService.dll:UserAccountService" | 54 | LocalServiceModule = "OpenSim.Services.UserAccountService.dll:UserAccountService" |
58 | StorageProvider = "OpenSim.Data.Null.dll" | 55 | ConnectionString = "URI=file:userprofiles.db,version=3" |
59 | ;; These are for creating new accounts | 56 | ;; These are for creating new accounts |
60 | AuthenticationService = "OpenSim.Services.AuthenticationService.dll:PasswordAuthenticationService" | 57 | AuthenticationService = "OpenSim.Services.AuthenticationService.dll:PasswordAuthenticationService" |
61 | PresenceService = "OpenSim.Services.PresenceService.dll:PresenceService" | 58 | PresenceService = "OpenSim.Services.PresenceService.dll:PresenceService" |
@@ -72,3 +69,8 @@ | |||
72 | AvatarService = "OpenSim.Services.AvatarService.dll:AvatarService" | 69 | AvatarService = "OpenSim.Services.AvatarService.dll:AvatarService" |
73 | 70 | ||
74 | WelcomeMessage = "Welcome, Avatar!" | 71 | WelcomeMessage = "Welcome, Avatar!" |
72 | |||
73 | |||
74 | ;; This should always be the very last thing on this file | ||
75 | [Includes] | ||
76 | Include-Common = "config-include/StandaloneCommon.ini" | ||
diff --git a/bin/config-include/StandaloneHypergrid.ini b/bin/config-include/StandaloneHypergrid.ini index a4fa5be..04a2356 100644 --- a/bin/config-include/StandaloneHypergrid.ini +++ b/bin/config-include/StandaloneHypergrid.ini | |||
@@ -3,9 +3,6 @@ | |||
3 | ;; All optional settings are in StandaloneCommon.ini.example, | 3 | ;; All optional settings are in StandaloneCommon.ini.example, |
4 | ;; which you can copy and change. | 4 | ;; which you can copy and change. |
5 | ;; | 5 | ;; |
6 | |||
7 | [Includes] | ||
8 | Include-Common = "config-include/StandaloneCommon.ini" | ||
9 | 6 | ||
10 | [Modules] | 7 | [Modules] |
11 | AssetServices = "HGAssetBroker" | 8 | AssetServices = "HGAssetBroker" |
@@ -45,7 +42,7 @@ | |||
45 | 42 | ||
46 | [AvatarService] | 43 | [AvatarService] |
47 | LocalServiceModule = "OpenSim.Services.AvatarService.dll:AvatarService" | 44 | LocalServiceModule = "OpenSim.Services.AvatarService.dll:AvatarService" |
48 | StorageProvider = "OpenSim.Data.Null.dll" | 45 | ConnectionString = "URI=file:avatars.db,version=3" |
49 | 46 | ||
50 | [LibraryService] | 47 | [LibraryService] |
51 | LocalServiceModule = "OpenSim.Services.InventoryService.dll:LibraryService" | 48 | LocalServiceModule = "OpenSim.Services.InventoryService.dll:LibraryService" |
@@ -57,7 +54,7 @@ | |||
57 | 54 | ||
58 | [AuthenticationService] | 55 | [AuthenticationService] |
59 | LocalServiceModule = "OpenSim.Services.AuthenticationService.dll:PasswordAuthenticationService" | 56 | LocalServiceModule = "OpenSim.Services.AuthenticationService.dll:PasswordAuthenticationService" |
60 | StorageProvider = "OpenSim.Data.Null.dll" | 57 | ConnectionString = "URI=file:auth.db,version=3" |
61 | 58 | ||
62 | [GridService] | 59 | [GridService] |
63 | ; LocalGridServicesConnector needs this | 60 | ; LocalGridServicesConnector needs this |
@@ -73,7 +70,7 @@ | |||
73 | 70 | ||
74 | [UserAccountService] | 71 | [UserAccountService] |
75 | LocalServiceModule = "OpenSim.Services.UserAccountService.dll:UserAccountService" | 72 | LocalServiceModule = "OpenSim.Services.UserAccountService.dll:UserAccountService" |
76 | StorageProvider = "OpenSim.Data.Null.dll" | 73 | ConnectionString = "URI=file:userprofiles.db,version=3" |
77 | ;; These are for creating new accounts by the service | 74 | ;; These are for creating new accounts by the service |
78 | AuthenticationService = "OpenSim.Services.AuthenticationService.dll:PasswordAuthenticationService" | 75 | AuthenticationService = "OpenSim.Services.AuthenticationService.dll:PasswordAuthenticationService" |
79 | PresenceService = "OpenSim.Services.PresenceService.dll:PresenceService" | 76 | PresenceService = "OpenSim.Services.PresenceService.dll:PresenceService" |
@@ -112,3 +109,8 @@ | |||
112 | [HGInventoryService] | 109 | [HGInventoryService] |
113 | ; For the InventoryServiceInConnector | 110 | ; For the InventoryServiceInConnector |
114 | LocalServiceModule = "OpenSim.Services.InventoryService.dll:HGInventoryService" | 111 | LocalServiceModule = "OpenSim.Services.InventoryService.dll:HGInventoryService" |
112 | |||
113 | |||
114 | ;; This should always be the very last thing on this file | ||
115 | [Includes] | ||
116 | Include-Common = "config-include/StandaloneCommon.ini" | ||