diff options
Diffstat (limited to '')
32 files changed, 2630 insertions, 37 deletions
diff --git a/OpenSim/Data/IGridUserData.cs b/OpenSim/Data/IGridUserData.cs index e15a1f8..9afa477 100644 --- a/OpenSim/Data/IGridUserData.cs +++ b/OpenSim/Data/IGridUserData.cs | |||
@@ -50,6 +50,7 @@ namespace OpenSim.Data | |||
50 | public interface IGridUserData | 50 | public interface IGridUserData |
51 | { | 51 | { |
52 | GridUserData Get(string userID); | 52 | GridUserData Get(string userID); |
53 | GridUserData[] GetAll(string query); | ||
53 | bool Store(GridUserData data); | 54 | bool Store(GridUserData data); |
54 | } | 55 | } |
55 | } \ No newline at end of file | 56 | } \ No newline at end of file |
diff --git a/OpenSim/Data/IHGTravelingData.cs b/OpenSim/Data/IHGTravelingData.cs new file mode 100644 index 0000000..452af7b --- /dev/null +++ b/OpenSim/Data/IHGTravelingData.cs | |||
@@ -0,0 +1,59 @@ | |||
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 | // This MUST be a ref type! | ||
36 | public class HGTravelingData | ||
37 | { | ||
38 | public UUID SessionID; | ||
39 | public UUID UserID; | ||
40 | public Dictionary<string, string> Data; | ||
41 | |||
42 | public HGTravelingData() | ||
43 | { | ||
44 | Data = new Dictionary<string, string>(); | ||
45 | } | ||
46 | } | ||
47 | |||
48 | /// <summary> | ||
49 | /// An interface for connecting to the user grid datastore | ||
50 | /// </summary> | ||
51 | public interface IHGTravelingData | ||
52 | { | ||
53 | HGTravelingData Get(UUID sessionID); | ||
54 | HGTravelingData[] GetSessions(UUID userID); | ||
55 | bool Store(HGTravelingData data); | ||
56 | bool Delete(UUID sessionID); | ||
57 | void DeleteOld(); | ||
58 | } | ||
59 | } \ No newline at end of file | ||
diff --git a/OpenSim/Data/IProfilesData.cs b/OpenSim/Data/IProfilesData.cs new file mode 100644 index 0000000..0de7f68 --- /dev/null +++ b/OpenSim/Data/IProfilesData.cs | |||
@@ -0,0 +1,56 @@ | |||
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 | using OpenMetaverse.StructuredData; | ||
31 | using OpenSim.Framework; | ||
32 | |||
33 | namespace OpenSim.Data | ||
34 | { | ||
35 | |||
36 | public interface IProfilesData | ||
37 | { | ||
38 | OSDArray GetClassifiedRecords(UUID creatorId); | ||
39 | bool UpdateClassifiedRecord(UserClassifiedAdd ad, ref string result); | ||
40 | bool DeleteClassifiedRecord(UUID recordId); | ||
41 | OSDArray GetAvatarPicks(UUID avatarId); | ||
42 | UserProfilePick GetPickInfo(UUID avatarId, UUID pickId); | ||
43 | bool UpdatePicksRecord(UserProfilePick pick); | ||
44 | bool DeletePicksRecord(UUID pickId); | ||
45 | bool GetAvatarNotes(ref UserProfileNotes note); | ||
46 | bool UpdateAvatarNotes(ref UserProfileNotes note, ref string result); | ||
47 | bool GetAvatarProperties(ref UserProfileProperties props, ref string result); | ||
48 | bool UpdateAvatarProperties(ref UserProfileProperties props, ref string result); | ||
49 | bool UpdateAvatarInterests(UserProfileProperties up, ref string result); | ||
50 | bool GetClassifiedInfo(ref UserClassifiedAdd ad, ref string result); | ||
51 | bool GetUserAppData(ref UserAppData props, ref string result); | ||
52 | bool SetUserAppData(UserAppData props, ref string result); | ||
53 | OSDArray GetUserImageAssets(UUID avatarId); | ||
54 | } | ||
55 | } | ||
56 | |||
diff --git a/OpenSim/Data/IRegionData.cs b/OpenSim/Data/IRegionData.cs index 70e1065..463c621 100644 --- a/OpenSim/Data/IRegionData.cs +++ b/OpenSim/Data/IRegionData.cs | |||
@@ -81,6 +81,7 @@ namespace OpenSim.Data | |||
81 | bool Delete(UUID regionID); | 81 | bool Delete(UUID regionID); |
82 | 82 | ||
83 | List<RegionData> GetDefaultRegions(UUID scopeID); | 83 | List<RegionData> GetDefaultRegions(UUID scopeID); |
84 | List<RegionData> GetDefaultHypergridRegions(UUID scopeID); | ||
84 | List<RegionData> GetFallbackRegions(UUID scopeID, int x, int y); | 85 | List<RegionData> GetFallbackRegions(UUID scopeID, int x, int y); |
85 | List<RegionData> GetHyperlinks(UUID scopeID); | 86 | List<RegionData> GetHyperlinks(UUID scopeID); |
86 | } | 87 | } |
diff --git a/OpenSim/Data/MSSQL/MSSQLGridUserData.cs b/OpenSim/Data/MSSQL/MSSQLGridUserData.cs index 1870273..fd52122 100644 --- a/OpenSim/Data/MSSQL/MSSQLGridUserData.cs +++ b/OpenSim/Data/MSSQL/MSSQLGridUserData.cs | |||
@@ -50,7 +50,7 @@ namespace OpenSim.Data.MSSQL | |||
50 | { | 50 | { |
51 | } | 51 | } |
52 | 52 | ||
53 | public GridUserData Get(string userID) | 53 | public new GridUserData Get(string userID) |
54 | { | 54 | { |
55 | GridUserData[] ret = Get("UserID", userID); | 55 | GridUserData[] ret = Get("UserID", userID); |
56 | 56 | ||
@@ -60,5 +60,10 @@ namespace OpenSim.Data.MSSQL | |||
60 | return ret[0]; | 60 | return ret[0]; |
61 | } | 61 | } |
62 | 62 | ||
63 | public GridUserData[] GetAll(string userID) | ||
64 | { | ||
65 | return base.Get(String.Format("UserID LIKE '{0}%'", userID)); | ||
66 | } | ||
67 | |||
63 | } | 68 | } |
64 | } | 69 | } |
diff --git a/OpenSim/Data/MSSQL/MSSQLRegionData.cs b/OpenSim/Data/MSSQL/MSSQLRegionData.cs index 0d89706..c0589df 100644 --- a/OpenSim/Data/MSSQL/MSSQLRegionData.cs +++ b/OpenSim/Data/MSSQL/MSSQLRegionData.cs | |||
@@ -315,6 +315,11 @@ namespace OpenSim.Data.MSSQL | |||
315 | return Get((int)RegionFlags.DefaultRegion, scopeID); | 315 | return Get((int)RegionFlags.DefaultRegion, scopeID); |
316 | } | 316 | } |
317 | 317 | ||
318 | public List<RegionData> GetDefaultHypergridRegions(UUID scopeID) | ||
319 | { | ||
320 | return Get((int)RegionFlags.DefaultHGRegion, scopeID); | ||
321 | } | ||
322 | |||
318 | public List<RegionData> GetFallbackRegions(UUID scopeID, int x, int y) | 323 | public List<RegionData> GetFallbackRegions(UUID scopeID, int x, int y) |
319 | { | 324 | { |
320 | List<RegionData> regions = Get((int)RegionFlags.FallbackRegion, scopeID); | 325 | List<RegionData> regions = Get((int)RegionFlags.FallbackRegion, scopeID); |
diff --git a/OpenSim/Data/MSSQL/MSSQLSimulationData.cs b/OpenSim/Data/MSSQL/MSSQLSimulationData.cs index 00af3a0..bc5beeb 100644 --- a/OpenSim/Data/MSSQL/MSSQLSimulationData.cs +++ b/OpenSim/Data/MSSQL/MSSQLSimulationData.cs | |||
@@ -2100,7 +2100,7 @@ VALUES | |||
2100 | parameters.Add(_Database.CreateParameter("LinkNumber", prim.LinkNum)); | 2100 | parameters.Add(_Database.CreateParameter("LinkNumber", prim.LinkNum)); |
2101 | parameters.Add(_Database.CreateParameter("MediaURL", prim.MediaUrl)); | 2101 | parameters.Add(_Database.CreateParameter("MediaURL", prim.MediaUrl)); |
2102 | 2102 | ||
2103 | if (prim.DynAttrs.Count > 0) | 2103 | if (prim.DynAttrs.CountNamespaces > 0) |
2104 | parameters.Add(_Database.CreateParameter("DynAttrs", prim.DynAttrs.ToXml())); | 2104 | parameters.Add(_Database.CreateParameter("DynAttrs", prim.DynAttrs.ToXml())); |
2105 | else | 2105 | else |
2106 | parameters.Add(_Database.CreateParameter("DynAttrs", null)); | 2106 | parameters.Add(_Database.CreateParameter("DynAttrs", null)); |
diff --git a/OpenSim/Data/MSSQL/Resources/RegionStore.migrations b/OpenSim/Data/MSSQL/Resources/RegionStore.migrations index b84c2a4..4549801 100644 --- a/OpenSim/Data/MSSQL/Resources/RegionStore.migrations +++ b/OpenSim/Data/MSSQL/Resources/RegionStore.migrations | |||
@@ -1153,7 +1153,7 @@ COMMIT | |||
1153 | 1153 | ||
1154 | BEGIN TRANSACTION | 1154 | BEGIN TRANSACTION |
1155 | 1155 | ||
1156 | ALTER TABLE prims ADD COLUMN DynAttrs TEXT; | 1156 | ALTER TABLE prims ADD DynAttrs TEXT; |
1157 | 1157 | ||
1158 | COMMIT | 1158 | COMMIT |
1159 | 1159 | ||
@@ -1161,10 +1161,10 @@ COMMIT | |||
1161 | 1161 | ||
1162 | BEGIN TRANSACTION | 1162 | BEGIN TRANSACTION |
1163 | 1163 | ||
1164 | ALTER TABLE prims ADD COLUMN `PhysicsShapeType` tinyint(4) NOT NULL default '0'; | 1164 | ALTER TABLE prims ADD `PhysicsShapeType` tinyint(4) NOT NULL default '0'; |
1165 | ALTER TABLE prims ADD COLUMN `Density` double NOT NULL default '1000'; | 1165 | ALTER TABLE prims ADD `Density` double NOT NULL default '1000'; |
1166 | ALTER TABLE prims ADD COLUMN `GravityModifier` double NOT NULL default '1'; | 1166 | ALTER TABLE prims ADD `GravityModifier` double NOT NULL default '1'; |
1167 | ALTER TABLE prims ADD COLUMN `Friction` double NOT NULL default '0.6'; | 1167 | ALTER TABLE prims ADD `Friction` double NOT NULL default '0.6'; |
1168 | ALTER TABLE prims ADD COLUMN `Restitution` double NOT NULL default '0.5'; | 1168 | ALTER TABLE prims ADD `Restitution` double NOT NULL default '0.5'; |
1169 | 1169 | ||
1170 | COMMIT | 1170 | COMMIT |
diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index 21dd5aa..59cc22a 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs | |||
@@ -142,7 +142,8 @@ namespace OpenSim.Data.MySQL | |||
142 | } | 142 | } |
143 | catch (Exception e) | 143 | catch (Exception e) |
144 | { | 144 | { |
145 | m_log.Error("[ASSETS DB]: MySql failure fetching asset " + assetID + ": " + e.Message); | 145 | m_log.Error( |
146 | string.Format("[ASSETS DB]: MySql failure fetching asset {0}. Exception ", assetID), e); | ||
146 | } | 147 | } |
147 | } | 148 | } |
148 | } | 149 | } |
@@ -243,10 +244,11 @@ namespace OpenSim.Data.MySQL | |||
243 | } | 244 | } |
244 | catch (Exception e) | 245 | catch (Exception e) |
245 | { | 246 | { |
246 | m_log.ErrorFormat( | 247 | m_log.Error( |
247 | "[ASSETS DB]: " + | 248 | string.Format( |
248 | "MySql failure updating access_time for asset {0} with name {1}" + Environment.NewLine + e.ToString() | 249 | "[ASSETS DB]: Failure updating access_time for asset {0} with name {1}. Exception ", |
249 | + Environment.NewLine + "Attempting reconnection", asset.FullID, asset.Name); | 250 | asset.FullID, asset.Name), |
251 | e); | ||
250 | } | 252 | } |
251 | } | 253 | } |
252 | } | 254 | } |
@@ -286,8 +288,8 @@ namespace OpenSim.Data.MySQL | |||
286 | } | 288 | } |
287 | catch (Exception e) | 289 | catch (Exception e) |
288 | { | 290 | { |
289 | m_log.ErrorFormat( | 291 | m_log.Error( |
290 | "[ASSETS DB]: MySql failure fetching asset {0}" + Environment.NewLine + e.ToString(), uuid); | 292 | string.Format("[ASSETS DB]: MySql failure fetching asset {0}. Exception ", uuid), e); |
291 | } | 293 | } |
292 | } | 294 | } |
293 | } | 295 | } |
@@ -346,7 +348,11 @@ namespace OpenSim.Data.MySQL | |||
346 | } | 348 | } |
347 | catch (Exception e) | 349 | catch (Exception e) |
348 | { | 350 | { |
349 | m_log.Error("[ASSETS DB]: MySql failure fetching asset set" + Environment.NewLine + e.ToString()); | 351 | m_log.Error( |
352 | string.Format( | ||
353 | "[ASSETS DB]: MySql failure fetching asset set from {0}, count {1}. Exception ", | ||
354 | start, count), | ||
355 | e); | ||
350 | } | 356 | } |
351 | } | 357 | } |
352 | } | 358 | } |
diff --git a/OpenSim/Data/MySQL/MySQLGridUserData.cs b/OpenSim/Data/MySQL/MySQLGridUserData.cs index a9ce94d..00560c1 100644 --- a/OpenSim/Data/MySQL/MySQLGridUserData.cs +++ b/OpenSim/Data/MySQL/MySQLGridUserData.cs | |||
@@ -46,7 +46,7 @@ namespace OpenSim.Data.MySQL | |||
46 | 46 | ||
47 | public MySQLGridUserData(string connectionString, string realm) : base(connectionString, realm, "GridUserStore") {} | 47 | public MySQLGridUserData(string connectionString, string realm) : base(connectionString, realm, "GridUserStore") {} |
48 | 48 | ||
49 | public GridUserData Get(string userID) | 49 | public new GridUserData Get(string userID) |
50 | { | 50 | { |
51 | GridUserData[] ret = Get("UserID", userID); | 51 | GridUserData[] ret = Get("UserID", userID); |
52 | 52 | ||
@@ -56,6 +56,9 @@ namespace OpenSim.Data.MySQL | |||
56 | return ret[0]; | 56 | return ret[0]; |
57 | } | 57 | } |
58 | 58 | ||
59 | 59 | public GridUserData[] GetAll(string userID) | |
60 | { | ||
61 | return base.Get(String.Format("UserID LIKE '{0}%'", userID)); | ||
62 | } | ||
60 | } | 63 | } |
61 | } \ No newline at end of file | 64 | } \ No newline at end of file |
diff --git a/OpenSim/Data/MySQL/MySQLGroupsData.cs b/OpenSim/Data/MySQL/MySQLGroupsData.cs index 2a1bd6c..0318284 100644 --- a/OpenSim/Data/MySQL/MySQLGroupsData.cs +++ b/OpenSim/Data/MySQL/MySQLGroupsData.cs | |||
@@ -88,7 +88,7 @@ namespace OpenSim.Data.MySQL | |||
88 | if (string.IsNullOrEmpty(pattern)) | 88 | if (string.IsNullOrEmpty(pattern)) |
89 | pattern = "1 ORDER BY Name LIMIT 100"; | 89 | pattern = "1 ORDER BY Name LIMIT 100"; |
90 | else | 90 | else |
91 | pattern = string.Format("Name LIKE %{0}% ORDER BY Name LIMIT 100", pattern); | 91 | pattern = string.Format("Name LIKE '%{0}%' ORDER BY Name LIMIT 100", pattern); |
92 | 92 | ||
93 | return m_Groups.Get(pattern); | 93 | return m_Groups.Get(pattern); |
94 | } | 94 | } |
diff --git a/OpenSim/Data/MySQL/MySQLHGTravelData.cs b/OpenSim/Data/MySQL/MySQLHGTravelData.cs new file mode 100644 index 0000000..e81b880 --- /dev/null +++ b/OpenSim/Data/MySQL/MySQLHGTravelData.cs | |||
@@ -0,0 +1,80 @@ | |||
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 OpenMetaverse; | ||
35 | using OpenSim.Framework; | ||
36 | using MySql.Data.MySqlClient; | ||
37 | |||
38 | namespace OpenSim.Data.MySQL | ||
39 | { | ||
40 | /// <summary> | ||
41 | /// A MySQL Interface for user grid data | ||
42 | /// </summary> | ||
43 | public class MySQLHGTravelData : MySQLGenericTableHandler<HGTravelingData>, IHGTravelingData | ||
44 | { | ||
45 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
46 | |||
47 | public MySQLHGTravelData(string connectionString, string realm) : base(connectionString, realm, "HGTravelStore") { } | ||
48 | |||
49 | public HGTravelingData Get(UUID sessionID) | ||
50 | { | ||
51 | HGTravelingData[] ret = Get("SessionID", sessionID.ToString()); | ||
52 | |||
53 | if (ret.Length == 0) | ||
54 | return null; | ||
55 | |||
56 | return ret[0]; | ||
57 | } | ||
58 | |||
59 | public HGTravelingData[] GetSessions(UUID userID) | ||
60 | { | ||
61 | return base.Get("UserID", userID.ToString()); | ||
62 | } | ||
63 | |||
64 | public bool Delete(UUID sessionID) | ||
65 | { | ||
66 | return Delete("SessionID", sessionID.ToString()); | ||
67 | } | ||
68 | |||
69 | public void DeleteOld() | ||
70 | { | ||
71 | using (MySqlCommand cmd = new MySqlCommand()) | ||
72 | { | ||
73 | cmd.CommandText = String.Format("delete from {0} where TMStamp < NOW() - INTERVAL 2 DAY", m_Realm); | ||
74 | |||
75 | ExecuteNonQuery(cmd); | ||
76 | } | ||
77 | |||
78 | } | ||
79 | } | ||
80 | } \ No newline at end of file | ||
diff --git a/OpenSim/Data/MySQL/MySQLOfflineIMData.cs b/OpenSim/Data/MySQL/MySQLOfflineIMData.cs index 252f358..bafd204 100644 --- a/OpenSim/Data/MySQL/MySQLOfflineIMData.cs +++ b/OpenSim/Data/MySQL/MySQLOfflineIMData.cs | |||
@@ -47,13 +47,10 @@ namespace OpenSim.Data.MySQL | |||
47 | 47 | ||
48 | public void DeleteOld() | 48 | public void DeleteOld() |
49 | { | 49 | { |
50 | uint now = (uint)Util.UnixTimeSinceEpoch(); | ||
51 | |||
52 | using (MySqlCommand cmd = new MySqlCommand()) | 50 | using (MySqlCommand cmd = new MySqlCommand()) |
53 | { | 51 | { |
54 | cmd.CommandText = String.Format("delete from {0} where TMStamp < ?tstamp", m_Realm); | 52 | cmd.CommandText = String.Format("delete from {0} where TMStamp < NOW() - INTERVAL 2 WEEK", m_Realm); |
55 | cmd.Parameters.AddWithValue("?tstamp", now - 14 * 24 * 60 * 60); // > 2 weeks old | 53 | |
56 | |||
57 | ExecuteNonQuery(cmd); | 54 | ExecuteNonQuery(cmd); |
58 | } | 55 | } |
59 | 56 | ||
diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index a2d4ae4..2ad7590 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs | |||
@@ -310,6 +310,11 @@ namespace OpenSim.Data.MySQL | |||
310 | return Get((int)RegionFlags.DefaultRegion, scopeID); | 310 | return Get((int)RegionFlags.DefaultRegion, scopeID); |
311 | } | 311 | } |
312 | 312 | ||
313 | public List<RegionData> GetDefaultHypergridRegions(UUID scopeID) | ||
314 | { | ||
315 | return Get((int)RegionFlags.DefaultHGRegion, scopeID); | ||
316 | } | ||
317 | |||
313 | public List<RegionData> GetFallbackRegions(UUID scopeID, int x, int y) | 318 | public List<RegionData> GetFallbackRegions(UUID scopeID, int x, int y) |
314 | { | 319 | { |
315 | List<RegionData> regions = Get((int)RegionFlags.FallbackRegion, scopeID); | 320 | List<RegionData> regions = Get((int)RegionFlags.FallbackRegion, scopeID); |
diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs index 537ec85..feacbb2 100644 --- a/OpenSim/Data/MySQL/MySQLSimulationData.cs +++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs | |||
@@ -1730,7 +1730,7 @@ namespace OpenSim.Data.MySQL | |||
1730 | else | 1730 | else |
1731 | cmd.Parameters.AddWithValue("Vehicle", String.Empty); | 1731 | cmd.Parameters.AddWithValue("Vehicle", String.Empty); |
1732 | 1732 | ||
1733 | if (prim.DynAttrs.Count > 0) | 1733 | if (prim.DynAttrs.CountNamespaces > 0) |
1734 | cmd.Parameters.AddWithValue("DynAttrs", prim.DynAttrs.ToXml()); | 1734 | cmd.Parameters.AddWithValue("DynAttrs", prim.DynAttrs.ToXml()); |
1735 | else | 1735 | else |
1736 | cmd.Parameters.AddWithValue("DynAttrs", null); | 1736 | cmd.Parameters.AddWithValue("DynAttrs", null); |
diff --git a/OpenSim/Data/MySQL/MySQLUserProfilesData.cs b/OpenSim/Data/MySQL/MySQLUserProfilesData.cs new file mode 100644 index 0000000..4c6c8e3 --- /dev/null +++ b/OpenSim/Data/MySQL/MySQLUserProfilesData.cs | |||
@@ -0,0 +1,1096 @@ | |||
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.Data; | ||
30 | using System.Reflection; | ||
31 | using OpenSim.Data; | ||
32 | using OpenSim.Framework; | ||
33 | using MySql.Data.MySqlClient; | ||
34 | using OpenMetaverse; | ||
35 | using OpenMetaverse.StructuredData; | ||
36 | using log4net; | ||
37 | |||
38 | namespace OpenSim.Data.MySQL | ||
39 | { | ||
40 | public class UserProfilesData: IProfilesData | ||
41 | { | ||
42 | static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
43 | |||
44 | #region Properites | ||
45 | string ConnectionString | ||
46 | { | ||
47 | get; set; | ||
48 | } | ||
49 | |||
50 | protected object Lock | ||
51 | { | ||
52 | get; set; | ||
53 | } | ||
54 | |||
55 | protected virtual Assembly Assembly | ||
56 | { | ||
57 | get { return GetType().Assembly; } | ||
58 | } | ||
59 | |||
60 | #endregion Properties | ||
61 | |||
62 | #region class Member Functions | ||
63 | public UserProfilesData(string connectionString) | ||
64 | { | ||
65 | ConnectionString = connectionString; | ||
66 | Init(); | ||
67 | } | ||
68 | |||
69 | void Init() | ||
70 | { | ||
71 | using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) | ||
72 | { | ||
73 | dbcon.Open(); | ||
74 | |||
75 | Migration m = new Migration(dbcon, Assembly, "UserProfiles"); | ||
76 | m.Update(); | ||
77 | } | ||
78 | } | ||
79 | #endregion Member Functions | ||
80 | |||
81 | #region Classifieds Queries | ||
82 | /// <summary> | ||
83 | /// Gets the classified records. | ||
84 | /// </summary> | ||
85 | /// <returns> | ||
86 | /// Array of classified records | ||
87 | /// </returns> | ||
88 | /// <param name='creatorId'> | ||
89 | /// Creator identifier. | ||
90 | /// </param> | ||
91 | public OSDArray GetClassifiedRecords(UUID creatorId) | ||
92 | { | ||
93 | OSDArray data = new OSDArray(); | ||
94 | |||
95 | using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) | ||
96 | { | ||
97 | string query = "SELECT classifieduuid, name FROM classifieds WHERE creatoruuid = ?Id"; | ||
98 | dbcon.Open(); | ||
99 | using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) | ||
100 | { | ||
101 | cmd.Parameters.AddWithValue("?Id", creatorId); | ||
102 | using( MySqlDataReader reader = cmd.ExecuteReader(CommandBehavior.Default)) | ||
103 | { | ||
104 | if(reader.HasRows) | ||
105 | { | ||
106 | while (reader.Read()) | ||
107 | { | ||
108 | OSDMap n = new OSDMap(); | ||
109 | UUID Id = UUID.Zero; | ||
110 | |||
111 | string Name = null; | ||
112 | try | ||
113 | { | ||
114 | UUID.TryParse(Convert.ToString( reader["classifieduuid"]), out Id); | ||
115 | Name = Convert.ToString(reader["name"]); | ||
116 | } | ||
117 | catch (Exception e) | ||
118 | { | ||
119 | m_log.DebugFormat("[PROFILES_DATA]" + | ||
120 | ": UserAccount exception {0}", e.Message); | ||
121 | } | ||
122 | n.Add("classifieduuid", OSD.FromUUID(Id)); | ||
123 | n.Add("name", OSD.FromString(Name)); | ||
124 | data.Add(n); | ||
125 | } | ||
126 | } | ||
127 | } | ||
128 | } | ||
129 | } | ||
130 | return data; | ||
131 | } | ||
132 | |||
133 | public bool UpdateClassifiedRecord(UserClassifiedAdd ad, ref string result) | ||
134 | { | ||
135 | string query = string.Empty; | ||
136 | |||
137 | |||
138 | query += "INSERT INTO classifieds ("; | ||
139 | query += "`classifieduuid`,"; | ||
140 | query += "`creatoruuid`,"; | ||
141 | query += "`creationdate`,"; | ||
142 | query += "`expirationdate`,"; | ||
143 | query += "`category`,"; | ||
144 | query += "`name`,"; | ||
145 | query += "`description`,"; | ||
146 | query += "`parceluuid`,"; | ||
147 | query += "`parentestate`,"; | ||
148 | query += "`snapshotuuid`,"; | ||
149 | query += "`simname`,"; | ||
150 | query += "`posglobal`,"; | ||
151 | query += "`parcelname`,"; | ||
152 | query += "`classifiedflags`,"; | ||
153 | query += "`priceforlisting`) "; | ||
154 | query += "VALUES ("; | ||
155 | query += "?ClassifiedId,"; | ||
156 | query += "?CreatorId,"; | ||
157 | query += "?CreatedDate,"; | ||
158 | query += "?ExpirationDate,"; | ||
159 | query += "?Category,"; | ||
160 | query += "?Name,"; | ||
161 | query += "?Description,"; | ||
162 | query += "?ParcelId,"; | ||
163 | query += "?ParentEstate,"; | ||
164 | query += "?SnapshotId,"; | ||
165 | query += "?SimName,"; | ||
166 | query += "?GlobalPos,"; | ||
167 | query += "?ParcelName,"; | ||
168 | query += "?Flags,"; | ||
169 | query += "?ListingPrice ) "; | ||
170 | query += "ON DUPLICATE KEY UPDATE "; | ||
171 | query += "category=?Category, "; | ||
172 | query += "expirationdate=?ExpirationDate, "; | ||
173 | query += "name=?Name, "; | ||
174 | query += "description=?Description, "; | ||
175 | query += "parentestate=?ParentEstate, "; | ||
176 | query += "posglobal=?GlobalPos, "; | ||
177 | query += "parcelname=?ParcelName, "; | ||
178 | query += "classifiedflags=?Flags, "; | ||
179 | query += "priceforlisting=?ListingPrice, "; | ||
180 | query += "snapshotuuid=?SnapshotId"; | ||
181 | |||
182 | if(string.IsNullOrEmpty(ad.ParcelName)) | ||
183 | ad.ParcelName = "Unknown"; | ||
184 | if(ad.ParcelId == null) | ||
185 | ad.ParcelId = UUID.Zero; | ||
186 | if(string.IsNullOrEmpty(ad.Description)) | ||
187 | ad.Description = "No Description"; | ||
188 | |||
189 | DateTime epoch = new DateTime(1970, 1, 1); | ||
190 | DateTime now = DateTime.Now; | ||
191 | TimeSpan epochnow = now - epoch; | ||
192 | TimeSpan duration; | ||
193 | DateTime expiration; | ||
194 | TimeSpan epochexp; | ||
195 | |||
196 | if(ad.Flags == 2) | ||
197 | { | ||
198 | duration = new TimeSpan(7,0,0,0); | ||
199 | expiration = now.Add(duration); | ||
200 | epochexp = expiration - epoch; | ||
201 | } | ||
202 | else | ||
203 | { | ||
204 | duration = new TimeSpan(365,0,0,0); | ||
205 | expiration = now.Add(duration); | ||
206 | epochexp = expiration - epoch; | ||
207 | } | ||
208 | ad.CreationDate = (int)epochnow.TotalSeconds; | ||
209 | ad.ExpirationDate = (int)epochexp.TotalSeconds; | ||
210 | |||
211 | try | ||
212 | { | ||
213 | using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) | ||
214 | { | ||
215 | dbcon.Open(); | ||
216 | using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) | ||
217 | { | ||
218 | cmd.Parameters.AddWithValue("?ClassifiedId", ad.ClassifiedId.ToString()); | ||
219 | cmd.Parameters.AddWithValue("?CreatorId", ad.CreatorId.ToString()); | ||
220 | cmd.Parameters.AddWithValue("?CreatedDate", ad.CreationDate.ToString()); | ||
221 | cmd.Parameters.AddWithValue("?ExpirationDate", ad.ExpirationDate.ToString()); | ||
222 | cmd.Parameters.AddWithValue("?Category", ad.Category.ToString()); | ||
223 | cmd.Parameters.AddWithValue("?Name", ad.Name.ToString()); | ||
224 | cmd.Parameters.AddWithValue("?Description", ad.Description.ToString()); | ||
225 | cmd.Parameters.AddWithValue("?ParcelId", ad.ParcelId.ToString()); | ||
226 | cmd.Parameters.AddWithValue("?ParentEstate", ad.ParentEstate.ToString()); | ||
227 | cmd.Parameters.AddWithValue("?SnapshotId", ad.SnapshotId.ToString ()); | ||
228 | cmd.Parameters.AddWithValue("?SimName", ad.SimName.ToString()); | ||
229 | cmd.Parameters.AddWithValue("?GlobalPos", ad.GlobalPos.ToString()); | ||
230 | cmd.Parameters.AddWithValue("?ParcelName", ad.ParcelName.ToString()); | ||
231 | cmd.Parameters.AddWithValue("?Flags", ad.Flags.ToString()); | ||
232 | cmd.Parameters.AddWithValue("?ListingPrice", ad.Price.ToString ()); | ||
233 | |||
234 | cmd.ExecuteNonQuery(); | ||
235 | } | ||
236 | } | ||
237 | } | ||
238 | catch (Exception e) | ||
239 | { | ||
240 | m_log.DebugFormat("[PROFILES_DATA]" + | ||
241 | ": ClassifiedesUpdate exception {0}", e.Message); | ||
242 | result = e.Message; | ||
243 | return false; | ||
244 | } | ||
245 | return true; | ||
246 | } | ||
247 | |||
248 | public bool DeleteClassifiedRecord(UUID recordId) | ||
249 | { | ||
250 | string query = string.Empty; | ||
251 | |||
252 | query += "DELETE FROM classifieds WHERE "; | ||
253 | query += "classifieduuid = ?ClasifiedId"; | ||
254 | |||
255 | try | ||
256 | { | ||
257 | using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) | ||
258 | { | ||
259 | dbcon.Open(); | ||
260 | |||
261 | using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) | ||
262 | { | ||
263 | cmd.Parameters.AddWithValue("?ClassifiedId", recordId.ToString()); | ||
264 | |||
265 | lock(Lock) | ||
266 | { | ||
267 | cmd.ExecuteNonQuery(); | ||
268 | } | ||
269 | } | ||
270 | } | ||
271 | } | ||
272 | catch (Exception e) | ||
273 | { | ||
274 | m_log.DebugFormat("[PROFILES_DATA]" + | ||
275 | ": DeleteClassifiedRecord exception {0}", e.Message); | ||
276 | return false; | ||
277 | } | ||
278 | return true; | ||
279 | } | ||
280 | |||
281 | public bool GetClassifiedInfo(ref UserClassifiedAdd ad, ref string result) | ||
282 | { | ||
283 | string query = string.Empty; | ||
284 | |||
285 | query += "SELECT * FROM classifieds WHERE "; | ||
286 | query += "classifieduuid = ?AdId"; | ||
287 | |||
288 | try | ||
289 | { | ||
290 | using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) | ||
291 | { | ||
292 | dbcon.Open(); | ||
293 | using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) | ||
294 | { | ||
295 | cmd.Parameters.AddWithValue("?AdId", ad.ClassifiedId.ToString()); | ||
296 | |||
297 | using (MySqlDataReader reader = cmd.ExecuteReader()) | ||
298 | { | ||
299 | if(reader.Read ()) | ||
300 | { | ||
301 | ad.CreatorId = new UUID(reader.GetGuid("creatoruuid")); | ||
302 | ad.ParcelId = new UUID(reader.GetGuid("parceluuid")); | ||
303 | ad.SnapshotId = new UUID(reader.GetGuid("snapshotuuid")); | ||
304 | ad.CreationDate = Convert.ToInt32(reader["creationdate"]); | ||
305 | ad.ExpirationDate = Convert.ToInt32(reader["expirationdate"]); | ||
306 | ad.ParentEstate = Convert.ToInt32(reader["parentestate"]); | ||
307 | ad.Flags = (byte)reader.GetUInt32("classifiedflags"); | ||
308 | ad.Category = reader.GetInt32("category"); | ||
309 | ad.Price = reader.GetInt16("priceforlisting"); | ||
310 | ad.Name = reader.GetString("name"); | ||
311 | ad.Description = reader.GetString("description"); | ||
312 | ad.SimName = reader.GetString("simname"); | ||
313 | ad.GlobalPos = reader.GetString("posglobal"); | ||
314 | ad.ParcelName = reader.GetString("parcelname"); | ||
315 | |||
316 | } | ||
317 | } | ||
318 | } | ||
319 | dbcon.Close(); | ||
320 | } | ||
321 | } | ||
322 | catch (Exception e) | ||
323 | { | ||
324 | m_log.DebugFormat("[PROFILES_DATA]" + | ||
325 | ": GetPickInfo exception {0}", e.Message); | ||
326 | } | ||
327 | return true; | ||
328 | } | ||
329 | #endregion Classifieds Queries | ||
330 | |||
331 | #region Picks Queries | ||
332 | public OSDArray GetAvatarPicks(UUID avatarId) | ||
333 | { | ||
334 | string query = string.Empty; | ||
335 | |||
336 | query += "SELECT `pickuuid`,`name` FROM userpicks WHERE "; | ||
337 | query += "creatoruuid = ?Id"; | ||
338 | OSDArray data = new OSDArray(); | ||
339 | |||
340 | try | ||
341 | { | ||
342 | using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) | ||
343 | { | ||
344 | dbcon.Open(); | ||
345 | using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) | ||
346 | { | ||
347 | cmd.Parameters.AddWithValue("?Id", avatarId.ToString()); | ||
348 | |||
349 | using (MySqlDataReader reader = cmd.ExecuteReader()) | ||
350 | { | ||
351 | if(reader.HasRows) | ||
352 | { | ||
353 | while (reader.Read()) | ||
354 | { | ||
355 | OSDMap record = new OSDMap(); | ||
356 | |||
357 | record.Add("pickuuid",OSD.FromString((string)reader["pickuuid"])); | ||
358 | record.Add("name",OSD.FromString((string)reader["name"])); | ||
359 | data.Add(record); | ||
360 | } | ||
361 | } | ||
362 | } | ||
363 | } | ||
364 | } | ||
365 | } | ||
366 | catch (Exception e) | ||
367 | { | ||
368 | m_log.DebugFormat("[PROFILES_DATA]" + | ||
369 | ": GetAvatarPicks exception {0}", e.Message); | ||
370 | } | ||
371 | return data; | ||
372 | } | ||
373 | |||
374 | public UserProfilePick GetPickInfo(UUID avatarId, UUID pickId) | ||
375 | { | ||
376 | string query = string.Empty; | ||
377 | UserProfilePick pick = new UserProfilePick(); | ||
378 | |||
379 | query += "SELECT * FROM userpicks WHERE "; | ||
380 | query += "creatoruuid = ?CreatorId AND "; | ||
381 | query += "pickuuid = ?PickId"; | ||
382 | |||
383 | try | ||
384 | { | ||
385 | using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) | ||
386 | { | ||
387 | dbcon.Open(); | ||
388 | using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) | ||
389 | { | ||
390 | cmd.Parameters.AddWithValue("?CreatorId", avatarId.ToString()); | ||
391 | cmd.Parameters.AddWithValue("?PickId", pickId.ToString()); | ||
392 | |||
393 | using (MySqlDataReader reader = cmd.ExecuteReader()) | ||
394 | { | ||
395 | if(reader.HasRows) | ||
396 | { | ||
397 | reader.Read(); | ||
398 | |||
399 | string description = (string)reader["description"]; | ||
400 | |||
401 | if (string.IsNullOrEmpty(description)) | ||
402 | description = "No description given."; | ||
403 | |||
404 | UUID.TryParse((string)reader["pickuuid"], out pick.PickId); | ||
405 | UUID.TryParse((string)reader["creatoruuid"], out pick.CreatorId); | ||
406 | UUID.TryParse((string)reader["parceluuid"], out pick.ParcelId); | ||
407 | UUID.TryParse((string)reader["snapshotuuid"], out pick.SnapshotId); | ||
408 | pick.GlobalPos = (string)reader["posglobal"]; | ||
409 | bool.TryParse((string)reader["toppick"], out pick.TopPick); | ||
410 | bool.TryParse((string)reader["enabled"], out pick.Enabled); | ||
411 | pick.Name = (string)reader["name"]; | ||
412 | pick.Desc = description; | ||
413 | pick.User = (string)reader["user"]; | ||
414 | pick.OriginalName = (string)reader["originalname"]; | ||
415 | pick.SimName = (string)reader["simname"]; | ||
416 | pick.SortOrder = (int)reader["sortorder"]; | ||
417 | } | ||
418 | } | ||
419 | } | ||
420 | dbcon.Close(); | ||
421 | } | ||
422 | } | ||
423 | catch (Exception e) | ||
424 | { | ||
425 | m_log.DebugFormat("[PROFILES_DATA]" + | ||
426 | ": GetPickInfo exception {0}", e.Message); | ||
427 | } | ||
428 | return pick; | ||
429 | } | ||
430 | |||
431 | public bool UpdatePicksRecord(UserProfilePick pick) | ||
432 | { | ||
433 | string query = string.Empty; | ||
434 | |||
435 | query += "INSERT INTO userpicks VALUES ("; | ||
436 | query += "?PickId,"; | ||
437 | query += "?CreatorId,"; | ||
438 | query += "?TopPick,"; | ||
439 | query += "?ParcelId,"; | ||
440 | query += "?Name,"; | ||
441 | query += "?Desc,"; | ||
442 | query += "?SnapshotId,"; | ||
443 | query += "?User,"; | ||
444 | query += "?Original,"; | ||
445 | query += "?SimName,"; | ||
446 | query += "?GlobalPos,"; | ||
447 | query += "?SortOrder,"; | ||
448 | query += "?Enabled) "; | ||
449 | query += "ON DUPLICATE KEY UPDATE "; | ||
450 | query += "parceluuid=?ParcelId,"; | ||
451 | query += "name=?Name,"; | ||
452 | query += "description=?Desc,"; | ||
453 | query += "snapshotuuid=?SnapshotId,"; | ||
454 | query += "pickuuid=?PickId,"; | ||
455 | query += "posglobal=?GlobalPos"; | ||
456 | |||
457 | try | ||
458 | { | ||
459 | using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) | ||
460 | { | ||
461 | dbcon.Open(); | ||
462 | using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) | ||
463 | { | ||
464 | cmd.Parameters.AddWithValue("?PickId", pick.PickId.ToString()); | ||
465 | cmd.Parameters.AddWithValue("?CreatorId", pick.CreatorId.ToString()); | ||
466 | cmd.Parameters.AddWithValue("?TopPick", pick.TopPick.ToString()); | ||
467 | cmd.Parameters.AddWithValue("?ParcelId", pick.ParcelId.ToString()); | ||
468 | cmd.Parameters.AddWithValue("?Name", pick.Name.ToString()); | ||
469 | cmd.Parameters.AddWithValue("?Desc", pick.Desc.ToString()); | ||
470 | cmd.Parameters.AddWithValue("?SnapshotId", pick.SnapshotId.ToString()); | ||
471 | cmd.Parameters.AddWithValue("?User", pick.User.ToString()); | ||
472 | cmd.Parameters.AddWithValue("?Original", pick.OriginalName.ToString()); | ||
473 | cmd.Parameters.AddWithValue("?SimName",pick.SimName.ToString()); | ||
474 | cmd.Parameters.AddWithValue("?GlobalPos", pick.GlobalPos); | ||
475 | cmd.Parameters.AddWithValue("?SortOrder", pick.SortOrder.ToString ()); | ||
476 | cmd.Parameters.AddWithValue("?Enabled", pick.Enabled.ToString()); | ||
477 | |||
478 | cmd.ExecuteNonQuery(); | ||
479 | } | ||
480 | } | ||
481 | } | ||
482 | catch (Exception e) | ||
483 | { | ||
484 | m_log.DebugFormat("[PROFILES_DATA]" + | ||
485 | ": UpdateAvatarNotes exception {0}", e.Message); | ||
486 | return false; | ||
487 | } | ||
488 | return true; | ||
489 | } | ||
490 | |||
491 | public bool DeletePicksRecord(UUID pickId) | ||
492 | { | ||
493 | string query = string.Empty; | ||
494 | |||
495 | query += "DELETE FROM userpicks WHERE "; | ||
496 | query += "pickuuid = ?PickId"; | ||
497 | |||
498 | try | ||
499 | { | ||
500 | using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) | ||
501 | { | ||
502 | dbcon.Open(); | ||
503 | |||
504 | using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) | ||
505 | { | ||
506 | cmd.Parameters.AddWithValue("?PickId", pickId.ToString()); | ||
507 | |||
508 | cmd.ExecuteNonQuery(); | ||
509 | } | ||
510 | } | ||
511 | } | ||
512 | catch (Exception e) | ||
513 | { | ||
514 | m_log.DebugFormat("[PROFILES_DATA]" + | ||
515 | ": DeleteUserPickRecord exception {0}", e.Message); | ||
516 | return false; | ||
517 | } | ||
518 | return true; | ||
519 | } | ||
520 | #endregion Picks Queries | ||
521 | |||
522 | #region Avatar Notes Queries | ||
523 | public bool GetAvatarNotes(ref UserProfileNotes notes) | ||
524 | { // WIP | ||
525 | string query = string.Empty; | ||
526 | |||
527 | query += "SELECT `notes` FROM usernotes WHERE "; | ||
528 | query += "useruuid = ?Id AND "; | ||
529 | query += "targetuuid = ?TargetId"; | ||
530 | OSDArray data = new OSDArray(); | ||
531 | |||
532 | try | ||
533 | { | ||
534 | using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) | ||
535 | { | ||
536 | dbcon.Open(); | ||
537 | using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) | ||
538 | { | ||
539 | cmd.Parameters.AddWithValue("?Id", notes.UserId.ToString()); | ||
540 | cmd.Parameters.AddWithValue("?TargetId", notes.TargetId.ToString()); | ||
541 | |||
542 | using (MySqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SingleRow)) | ||
543 | { | ||
544 | if(reader.HasRows) | ||
545 | { | ||
546 | reader.Read(); | ||
547 | notes.Notes = OSD.FromString((string)reader["notes"]); | ||
548 | } | ||
549 | } | ||
550 | } | ||
551 | } | ||
552 | } | ||
553 | catch (Exception e) | ||
554 | { | ||
555 | m_log.DebugFormat("[PROFILES_DATA]" + | ||
556 | ": GetAvatarNotes exception {0}", e.Message); | ||
557 | } | ||
558 | return true; | ||
559 | } | ||
560 | |||
561 | public bool UpdateAvatarNotes(ref UserProfileNotes note, ref string result) | ||
562 | { | ||
563 | string query = string.Empty; | ||
564 | bool remove; | ||
565 | |||
566 | if(string.IsNullOrEmpty(note.Notes)) | ||
567 | { | ||
568 | remove = true; | ||
569 | query += "DELETE FROM usernotes WHERE "; | ||
570 | query += "useruuid=?UserId AND "; | ||
571 | query += "targetuuid=?TargetId"; | ||
572 | } | ||
573 | else | ||
574 | { | ||
575 | remove = false; | ||
576 | query += "INSERT INTO usernotes VALUES ( "; | ||
577 | query += "?UserId,"; | ||
578 | query += "?TargetId,"; | ||
579 | query += "?Notes )"; | ||
580 | query += "ON DUPLICATE KEY "; | ||
581 | query += "UPDATE "; | ||
582 | query += "notes=?Notes"; | ||
583 | } | ||
584 | |||
585 | try | ||
586 | { | ||
587 | using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) | ||
588 | { | ||
589 | dbcon.Open(); | ||
590 | using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) | ||
591 | { | ||
592 | if(!remove) | ||
593 | cmd.Parameters.AddWithValue("?Notes", note.Notes); | ||
594 | cmd.Parameters.AddWithValue("?TargetId", note.TargetId.ToString ()); | ||
595 | cmd.Parameters.AddWithValue("?UserId", note.UserId.ToString()); | ||
596 | |||
597 | cmd.ExecuteNonQuery(); | ||
598 | } | ||
599 | } | ||
600 | } | ||
601 | catch (Exception e) | ||
602 | { | ||
603 | m_log.DebugFormat("[PROFILES_DATA]" + | ||
604 | ": UpdateAvatarNotes exception {0}", e.Message); | ||
605 | return false; | ||
606 | } | ||
607 | return true; | ||
608 | |||
609 | } | ||
610 | #endregion Avatar Notes Queries | ||
611 | |||
612 | #region Avatar Properties | ||
613 | public bool GetAvatarProperties(ref UserProfileProperties props, ref string result) | ||
614 | { | ||
615 | string query = string.Empty; | ||
616 | |||
617 | query += "SELECT * FROM userprofile WHERE "; | ||
618 | query += "useruuid = ?Id"; | ||
619 | |||
620 | try | ||
621 | { | ||
622 | using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) | ||
623 | { | ||
624 | dbcon.Open(); | ||
625 | using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) | ||
626 | { | ||
627 | cmd.Parameters.AddWithValue("?Id", props.UserId.ToString()); | ||
628 | |||
629 | using (MySqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SingleRow)) | ||
630 | { | ||
631 | if(reader.HasRows) | ||
632 | { | ||
633 | m_log.DebugFormat("[PROFILES_DATA]" + | ||
634 | ": Getting data for {0}.", props.UserId); | ||
635 | reader.Read(); | ||
636 | props.WebUrl = (string)reader["profileURL"]; | ||
637 | UUID.TryParse((string)reader["profileImage"], out props.ImageId); | ||
638 | props.AboutText = (string)reader["profileAboutText"]; | ||
639 | UUID.TryParse((string)reader["profileFirstImage"], out props.FirstLifeImageId); | ||
640 | props.FirstLifeText = (string)reader["profileFirstText"]; | ||
641 | UUID.TryParse((string)reader["profilePartner"], out props.PartnerId); | ||
642 | props.WantToMask = (int)reader["profileWantToMask"]; | ||
643 | props.WantToText = (string)reader["profileWantToText"]; | ||
644 | props.SkillsMask = (int)reader["profileSkillsMask"]; | ||
645 | props.SkillsText = (string)reader["profileSkillsText"]; | ||
646 | props.Language = (string)reader["profileLanguages"]; | ||
647 | } | ||
648 | else | ||
649 | { | ||
650 | m_log.DebugFormat("[PROFILES_DATA]" + | ||
651 | ": No data for {0}", props.UserId); | ||
652 | |||
653 | props.WebUrl = string.Empty; | ||
654 | props.ImageId = UUID.Zero; | ||
655 | props.AboutText = string.Empty; | ||
656 | props.FirstLifeImageId = UUID.Zero; | ||
657 | props.FirstLifeText = string.Empty; | ||
658 | props.PartnerId = UUID.Zero; | ||
659 | props.WantToMask = 0; | ||
660 | props.WantToText = string.Empty; | ||
661 | props.SkillsMask = 0; | ||
662 | props.SkillsText = string.Empty; | ||
663 | props.Language = string.Empty; | ||
664 | props.PublishProfile = false; | ||
665 | props.PublishMature = false; | ||
666 | |||
667 | query = "INSERT INTO userprofile ("; | ||
668 | query += "useruuid, "; | ||
669 | query += "profilePartner, "; | ||
670 | query += "profileAllowPublish, "; | ||
671 | query += "profileMaturePublish, "; | ||
672 | query += "profileURL, "; | ||
673 | query += "profileWantToMask, "; | ||
674 | query += "profileWantToText, "; | ||
675 | query += "profileSkillsMask, "; | ||
676 | query += "profileSkillsText, "; | ||
677 | query += "profileLanguages, "; | ||
678 | query += "profileImage, "; | ||
679 | query += "profileAboutText, "; | ||
680 | query += "profileFirstImage, "; | ||
681 | query += "profileFirstText) VALUES ("; | ||
682 | query += "?userId, "; | ||
683 | query += "?profilePartner, "; | ||
684 | query += "?profileAllowPublish, "; | ||
685 | query += "?profileMaturePublish, "; | ||
686 | query += "?profileURL, "; | ||
687 | query += "?profileWantToMask, "; | ||
688 | query += "?profileWantToText, "; | ||
689 | query += "?profileSkillsMask, "; | ||
690 | query += "?profileSkillsText, "; | ||
691 | query += "?profileLanguages, "; | ||
692 | query += "?profileImage, "; | ||
693 | query += "?profileAboutText, "; | ||
694 | query += "?profileFirstImage, "; | ||
695 | query += "?profileFirstText)"; | ||
696 | |||
697 | dbcon.Close(); | ||
698 | dbcon.Open(); | ||
699 | |||
700 | using (MySqlCommand put = new MySqlCommand(query, dbcon)) | ||
701 | { | ||
702 | put.Parameters.AddWithValue("?userId", props.UserId.ToString()); | ||
703 | put.Parameters.AddWithValue("?profilePartner", props.PartnerId.ToString()); | ||
704 | put.Parameters.AddWithValue("?profileAllowPublish", props.PublishProfile); | ||
705 | put.Parameters.AddWithValue("?profileMaturePublish", props.PublishMature); | ||
706 | put.Parameters.AddWithValue("?profileURL", props.WebUrl); | ||
707 | put.Parameters.AddWithValue("?profileWantToMask", props.WantToMask); | ||
708 | put.Parameters.AddWithValue("?profileWantToText", props.WantToText); | ||
709 | put.Parameters.AddWithValue("?profileSkillsMask", props.SkillsMask); | ||
710 | put.Parameters.AddWithValue("?profileSkillsText", props.SkillsText); | ||
711 | put.Parameters.AddWithValue("?profileLanguages", props.Language); | ||
712 | put.Parameters.AddWithValue("?profileImage", props.ImageId.ToString()); | ||
713 | put.Parameters.AddWithValue("?profileAboutText", props.AboutText); | ||
714 | put.Parameters.AddWithValue("?profileFirstImage", props.FirstLifeImageId.ToString()); | ||
715 | put.Parameters.AddWithValue("?profileFirstText", props.FirstLifeText); | ||
716 | |||
717 | put.ExecuteNonQuery(); | ||
718 | } | ||
719 | } | ||
720 | } | ||
721 | } | ||
722 | } | ||
723 | } | ||
724 | catch (Exception e) | ||
725 | { | ||
726 | m_log.DebugFormat("[PROFILES_DATA]" + | ||
727 | ": Requst properties exception {0}", e.Message); | ||
728 | result = e.Message; | ||
729 | return false; | ||
730 | } | ||
731 | return true; | ||
732 | } | ||
733 | |||
734 | public bool UpdateAvatarProperties(ref UserProfileProperties props, ref string result) | ||
735 | { | ||
736 | string query = string.Empty; | ||
737 | |||
738 | query += "UPDATE userprofile SET "; | ||
739 | query += "profilePartner=?profilePartner, "; | ||
740 | query += "profileURL=?profileURL, "; | ||
741 | query += "profileImage=?image, "; | ||
742 | query += "profileAboutText=?abouttext,"; | ||
743 | query += "profileFirstImage=?firstlifeimage,"; | ||
744 | query += "profileFirstText=?firstlifetext "; | ||
745 | query += "WHERE useruuid=?uuid"; | ||
746 | |||
747 | try | ||
748 | { | ||
749 | using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) | ||
750 | { | ||
751 | dbcon.Open(); | ||
752 | using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) | ||
753 | { | ||
754 | cmd.Parameters.AddWithValue("?profileURL", props.WebUrl); | ||
755 | cmd.Parameters.AddWithValue("?profilePartner", props.PartnerId.ToString()); | ||
756 | cmd.Parameters.AddWithValue("?image", props.ImageId.ToString()); | ||
757 | cmd.Parameters.AddWithValue("?abouttext", props.AboutText); | ||
758 | cmd.Parameters.AddWithValue("?firstlifeimage", props.FirstLifeImageId.ToString()); | ||
759 | cmd.Parameters.AddWithValue("?firstlifetext", props.FirstLifeText); | ||
760 | cmd.Parameters.AddWithValue("?uuid", props.UserId.ToString()); | ||
761 | |||
762 | cmd.ExecuteNonQuery(); | ||
763 | } | ||
764 | } | ||
765 | } | ||
766 | catch (Exception e) | ||
767 | { | ||
768 | m_log.DebugFormat("[PROFILES_DATA]" + | ||
769 | ": AgentPropertiesUpdate exception {0}", e.Message); | ||
770 | |||
771 | return false; | ||
772 | } | ||
773 | return true; | ||
774 | } | ||
775 | #endregion Avatar Properties | ||
776 | |||
777 | #region Avatar Interests | ||
778 | public bool UpdateAvatarInterests(UserProfileProperties up, ref string result) | ||
779 | { | ||
780 | string query = string.Empty; | ||
781 | |||
782 | query += "UPDATE userprofile SET "; | ||
783 | query += "profileWantToMask=?WantMask, "; | ||
784 | query += "profileWantToText=?WantText,"; | ||
785 | query += "profileSkillsMask=?SkillsMask,"; | ||
786 | query += "profileSkillsText=?SkillsText, "; | ||
787 | query += "profileLanguages=?Languages "; | ||
788 | query += "WHERE useruuid=?uuid"; | ||
789 | |||
790 | try | ||
791 | { | ||
792 | using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) | ||
793 | { | ||
794 | dbcon.Open(); | ||
795 | using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) | ||
796 | { | ||
797 | cmd.Parameters.AddWithValue("?WantMask", up.WantToMask); | ||
798 | cmd.Parameters.AddWithValue("?WantText", up.WantToText); | ||
799 | cmd.Parameters.AddWithValue("?SkillsMask", up.SkillsMask); | ||
800 | cmd.Parameters.AddWithValue("?SkillsText", up.SkillsText); | ||
801 | cmd.Parameters.AddWithValue("?Languages", up.Language); | ||
802 | cmd.Parameters.AddWithValue("?uuid", up.UserId.ToString()); | ||
803 | |||
804 | cmd.ExecuteNonQuery(); | ||
805 | } | ||
806 | } | ||
807 | } | ||
808 | catch (Exception e) | ||
809 | { | ||
810 | m_log.DebugFormat("[PROFILES_DATA]" + | ||
811 | ": AgentInterestsUpdate exception {0}", e.Message); | ||
812 | result = e.Message; | ||
813 | return false; | ||
814 | } | ||
815 | return true; | ||
816 | } | ||
817 | #endregion Avatar Interests | ||
818 | |||
819 | public OSDArray GetUserImageAssets(UUID avatarId) | ||
820 | { | ||
821 | OSDArray data = new OSDArray(); | ||
822 | string query = "SELECT `snapshotuuid` FROM {0} WHERE `creatoruuid` = ?Id"; | ||
823 | |||
824 | // Get classified image assets | ||
825 | |||
826 | |||
827 | try | ||
828 | { | ||
829 | using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) | ||
830 | { | ||
831 | dbcon.Open(); | ||
832 | |||
833 | using (MySqlCommand cmd = new MySqlCommand(string.Format (query,"`classifieds`"), dbcon)) | ||
834 | { | ||
835 | cmd.Parameters.AddWithValue("?Id", avatarId.ToString()); | ||
836 | |||
837 | using (MySqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SingleRow)) | ||
838 | { | ||
839 | if(reader.HasRows) | ||
840 | { | ||
841 | while (reader.Read()) | ||
842 | { | ||
843 | data.Add(new OSDString((string)reader["snapshotuuid"].ToString ())); | ||
844 | } | ||
845 | } | ||
846 | } | ||
847 | } | ||
848 | |||
849 | dbcon.Close(); | ||
850 | dbcon.Open(); | ||
851 | |||
852 | using (MySqlCommand cmd = new MySqlCommand(string.Format (query,"`userpicks`"), dbcon)) | ||
853 | { | ||
854 | cmd.Parameters.AddWithValue("?Id", avatarId.ToString()); | ||
855 | |||
856 | using (MySqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SingleRow)) | ||
857 | { | ||
858 | if(reader.HasRows) | ||
859 | { | ||
860 | while (reader.Read()) | ||
861 | { | ||
862 | data.Add(new OSDString((string)reader["snapshotuuid"].ToString ())); | ||
863 | } | ||
864 | } | ||
865 | } | ||
866 | } | ||
867 | |||
868 | dbcon.Close(); | ||
869 | dbcon.Open(); | ||
870 | |||
871 | query = "SELECT `profileImage`, `profileFirstImage` FROM `userprofile` WHERE `useruuid` = ?Id"; | ||
872 | |||
873 | using (MySqlCommand cmd = new MySqlCommand(string.Format (query,"`userpicks`"), dbcon)) | ||
874 | { | ||
875 | cmd.Parameters.AddWithValue("?Id", avatarId.ToString()); | ||
876 | |||
877 | using (MySqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SingleRow)) | ||
878 | { | ||
879 | if(reader.HasRows) | ||
880 | { | ||
881 | while (reader.Read()) | ||
882 | { | ||
883 | data.Add(new OSDString((string)reader["profileImage"].ToString ())); | ||
884 | data.Add(new OSDString((string)reader["profileFirstImage"].ToString ())); | ||
885 | } | ||
886 | } | ||
887 | } | ||
888 | } | ||
889 | } | ||
890 | } | ||
891 | catch (Exception e) | ||
892 | { | ||
893 | m_log.DebugFormat("[PROFILES_DATA]" + | ||
894 | ": GetAvatarNotes exception {0}", e.Message); | ||
895 | } | ||
896 | return data; | ||
897 | } | ||
898 | |||
899 | #region User Preferences | ||
900 | public OSDArray GetUserPreferences(UUID avatarId) | ||
901 | { | ||
902 | string query = string.Empty; | ||
903 | |||
904 | query += "SELECT imviaemail,visible,email FROM "; | ||
905 | query += "usersettings WHERE "; | ||
906 | query += "useruuid = ?Id"; | ||
907 | |||
908 | OSDArray data = new OSDArray(); | ||
909 | |||
910 | try | ||
911 | { | ||
912 | using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) | ||
913 | { | ||
914 | dbcon.Open(); | ||
915 | using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) | ||
916 | { | ||
917 | cmd.Parameters.AddWithValue("?Id", avatarId.ToString()); | ||
918 | |||
919 | using (MySqlDataReader reader = cmd.ExecuteReader()) | ||
920 | { | ||
921 | if(reader.HasRows) | ||
922 | { | ||
923 | reader.Read(); | ||
924 | OSDMap record = new OSDMap(); | ||
925 | |||
926 | record.Add("imviaemail",OSD.FromString((string)reader["imviaemail"])); | ||
927 | record.Add("visible",OSD.FromString((string)reader["visible"])); | ||
928 | record.Add("email",OSD.FromString((string)reader["email"])); | ||
929 | data.Add(record); | ||
930 | } | ||
931 | else | ||
932 | { | ||
933 | using (MySqlCommand put = new MySqlCommand(query, dbcon)) | ||
934 | { | ||
935 | query = "INSERT INTO usersettings VALUES "; | ||
936 | query += "(?Id,'false','false', '')"; | ||
937 | |||
938 | lock(Lock) | ||
939 | { | ||
940 | put.ExecuteNonQuery(); | ||
941 | } | ||
942 | } | ||
943 | } | ||
944 | } | ||
945 | } | ||
946 | } | ||
947 | } | ||
948 | catch (Exception e) | ||
949 | { | ||
950 | m_log.DebugFormat("[PROFILES_DATA]" + | ||
951 | ": Get preferences exception {0}", e.Message); | ||
952 | } | ||
953 | return data; | ||
954 | } | ||
955 | |||
956 | public bool UpdateUserPreferences(bool emailIm, bool visible, UUID avatarId ) | ||
957 | { | ||
958 | string query = string.Empty; | ||
959 | |||
960 | query += "UPDATE userpsettings SET "; | ||
961 | query += "imviaemail=?ImViaEmail, "; | ||
962 | query += "visible=?Visible,"; | ||
963 | query += "WHERE useruuid=?uuid"; | ||
964 | |||
965 | try | ||
966 | { | ||
967 | using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) | ||
968 | { | ||
969 | dbcon.Open(); | ||
970 | using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) | ||
971 | { | ||
972 | cmd.Parameters.AddWithValue("?ImViaEmail", emailIm.ToString().ToLower ()); | ||
973 | cmd.Parameters.AddWithValue("?WantText", visible.ToString().ToLower ()); | ||
974 | cmd.Parameters.AddWithValue("?uuid", avatarId.ToString()); | ||
975 | |||
976 | lock(Lock) | ||
977 | { | ||
978 | cmd.ExecuteNonQuery(); | ||
979 | } | ||
980 | } | ||
981 | } | ||
982 | } | ||
983 | catch (Exception e) | ||
984 | { | ||
985 | m_log.DebugFormat("[PROFILES_DATA]" + | ||
986 | ": AgentInterestsUpdate exception {0}", e.Message); | ||
987 | return false; | ||
988 | } | ||
989 | return true; | ||
990 | } | ||
991 | #endregion User Preferences | ||
992 | |||
993 | #region Integration | ||
994 | public bool GetUserAppData(ref UserAppData props, ref string result) | ||
995 | { | ||
996 | string query = string.Empty; | ||
997 | |||
998 | query += "SELECT * FROM `userdata` WHERE "; | ||
999 | query += "UserId = ?Id AND "; | ||
1000 | query += "TagId = ?TagId"; | ||
1001 | |||
1002 | try | ||
1003 | { | ||
1004 | using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) | ||
1005 | { | ||
1006 | dbcon.Open(); | ||
1007 | using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) | ||
1008 | { | ||
1009 | cmd.Parameters.AddWithValue("?Id", props.UserId.ToString()); | ||
1010 | cmd.Parameters.AddWithValue ("?TagId", props.TagId.ToString()); | ||
1011 | |||
1012 | using (MySqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SingleRow)) | ||
1013 | { | ||
1014 | if(reader.HasRows) | ||
1015 | { | ||
1016 | reader.Read(); | ||
1017 | props.DataKey = (string)reader["DataKey"]; | ||
1018 | props.DataVal = (string)reader["DataVal"]; | ||
1019 | } | ||
1020 | else | ||
1021 | { | ||
1022 | query += "INSERT INTO userdata VALUES ( "; | ||
1023 | query += "?UserId,"; | ||
1024 | query += "?TagId,"; | ||
1025 | query += "?DataKey,"; | ||
1026 | query += "?DataVal) "; | ||
1027 | |||
1028 | using (MySqlCommand put = new MySqlCommand(query, dbcon)) | ||
1029 | { | ||
1030 | put.Parameters.AddWithValue("?Id", props.UserId.ToString()); | ||
1031 | put.Parameters.AddWithValue("?TagId", props.TagId.ToString()); | ||
1032 | put.Parameters.AddWithValue("?DataKey", props.DataKey.ToString()); | ||
1033 | put.Parameters.AddWithValue("?DataVal", props.DataVal.ToString()); | ||
1034 | |||
1035 | lock(Lock) | ||
1036 | { | ||
1037 | put.ExecuteNonQuery(); | ||
1038 | } | ||
1039 | } | ||
1040 | } | ||
1041 | } | ||
1042 | } | ||
1043 | } | ||
1044 | } | ||
1045 | catch (Exception e) | ||
1046 | { | ||
1047 | m_log.DebugFormat("[PROFILES_DATA]" + | ||
1048 | ": Requst application data exception {0}", e.Message); | ||
1049 | result = e.Message; | ||
1050 | return false; | ||
1051 | } | ||
1052 | return true; | ||
1053 | } | ||
1054 | |||
1055 | public bool SetUserAppData(UserAppData props, ref string result) | ||
1056 | { | ||
1057 | string query = string.Empty; | ||
1058 | |||
1059 | query += "UPDATE userdata SET "; | ||
1060 | query += "TagId = ?TagId, "; | ||
1061 | query += "DataKey = ?DataKey, "; | ||
1062 | query += "DataVal = ?DataVal WHERE "; | ||
1063 | query += "UserId = ?UserId AND "; | ||
1064 | query += "TagId = ?TagId"; | ||
1065 | |||
1066 | try | ||
1067 | { | ||
1068 | using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) | ||
1069 | { | ||
1070 | dbcon.Open(); | ||
1071 | using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) | ||
1072 | { | ||
1073 | cmd.Parameters.AddWithValue("?UserId", props.UserId.ToString()); | ||
1074 | cmd.Parameters.AddWithValue("?TagId", props.TagId.ToString ()); | ||
1075 | cmd.Parameters.AddWithValue("?DataKey", props.DataKey.ToString ()); | ||
1076 | cmd.Parameters.AddWithValue("?DataVal", props.DataKey.ToString ()); | ||
1077 | |||
1078 | lock(Lock) | ||
1079 | { | ||
1080 | cmd.ExecuteNonQuery(); | ||
1081 | } | ||
1082 | } | ||
1083 | } | ||
1084 | } | ||
1085 | catch (Exception e) | ||
1086 | { | ||
1087 | m_log.DebugFormat("[PROFILES_DATA]" + | ||
1088 | ": SetUserData exception {0}", e.Message); | ||
1089 | return false; | ||
1090 | } | ||
1091 | return true; | ||
1092 | } | ||
1093 | #endregion Integration | ||
1094 | } | ||
1095 | } | ||
1096 | |||
diff --git a/OpenSim/Data/MySQL/MySQLXAssetData.cs b/OpenSim/Data/MySQL/MySQLXAssetData.cs index 15ac921..5f1d2ee 100644 --- a/OpenSim/Data/MySQL/MySQLXAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLXAssetData.cs | |||
@@ -199,6 +199,8 @@ namespace OpenSim.Data.MySQL | |||
199 | /// <remarks>On failure : Throw an exception and attempt to reconnect to database</remarks> | 199 | /// <remarks>On failure : Throw an exception and attempt to reconnect to database</remarks> |
200 | public void StoreAsset(AssetBase asset) | 200 | public void StoreAsset(AssetBase asset) |
201 | { | 201 | { |
202 | // m_log.DebugFormat("[XASSETS DB]: Storing asset {0} {1}", asset.Name, asset.ID); | ||
203 | |||
202 | lock (m_dbLock) | 204 | lock (m_dbLock) |
203 | { | 205 | { |
204 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 206 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
diff --git a/OpenSim/Data/MySQL/Resources/EstateStore.migrations b/OpenSim/Data/MySQL/Resources/EstateStore.migrations index df82a2e..2d1c2b5 100644 --- a/OpenSim/Data/MySQL/Resources/EstateStore.migrations +++ b/OpenSim/Data/MySQL/Resources/EstateStore.migrations | |||
@@ -77,5 +77,11 @@ BEGIN; | |||
77 | ALTER TABLE estate_settings AUTO_INCREMENT = 100; | 77 | ALTER TABLE estate_settings AUTO_INCREMENT = 100; |
78 | COMMIT; | 78 | COMMIT; |
79 | 79 | ||
80 | :VERSION 33 #--------------------- | ||
80 | 81 | ||
82 | BEGIN; | ||
83 | ALTER TABLE estate_settings ADD COLUMN `AllowLandmark` tinyint(4) NOT NULL default '1'; | ||
84 | ALTER TABLE estate_settings ADD COLUMN `AllowParcelChanges` tinyint(4) NOT NULL default '1'; | ||
85 | ALTER TABLE estate_settings ADD COLUMN `AllowSetHome` tinyint(4) NOT NULL default '1'; | ||
86 | COMMIT; | ||
81 | 87 | ||
diff --git a/OpenSim/Data/MySQL/Resources/FriendsStore.migrations b/OpenSim/Data/MySQL/Resources/FriendsStore.migrations index 55d82ec..5faf956 100644 --- a/OpenSim/Data/MySQL/Resources/FriendsStore.migrations +++ b/OpenSim/Data/MySQL/Resources/FriendsStore.migrations | |||
@@ -9,7 +9,7 @@ CREATE TABLE `Friends` ( | |||
9 | `Offered` VARCHAR(32) NOT NULL DEFAULT 0, | 9 | `Offered` VARCHAR(32) NOT NULL DEFAULT 0, |
10 | PRIMARY KEY(`PrincipalID`, `Friend`), | 10 | PRIMARY KEY(`PrincipalID`, `Friend`), |
11 | KEY(`PrincipalID`) | 11 | KEY(`PrincipalID`) |
12 | ); | 12 | ) ENGINE=InnoDB; |
13 | 13 | ||
14 | COMMIT; | 14 | COMMIT; |
15 | 15 | ||
diff --git a/OpenSim/Data/MySQL/Resources/HGTravelStore.migrations b/OpenSim/Data/MySQL/Resources/HGTravelStore.migrations new file mode 100644 index 0000000..b4e4422 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/HGTravelStore.migrations | |||
@@ -0,0 +1,18 @@ | |||
1 | :VERSION 1 # -------------------------- | ||
2 | |||
3 | BEGIN; | ||
4 | |||
5 | CREATE TABLE `hg_traveling_data` ( | ||
6 | `SessionID` VARCHAR(36) NOT NULL, | ||
7 | `UserID` VARCHAR(36) NOT NULL, | ||
8 | `GridExternalName` VARCHAR(255) NOT NULL DEFAULT '', | ||
9 | `ServiceToken` VARCHAR(255) NOT NULL DEFAULT '', | ||
10 | `ClientIPAddress` VARCHAR(16) NOT NULL DEFAULT '', | ||
11 | `MyIPAddress` VARCHAR(16) NOT NULL DEFAULT '', | ||
12 | `TMStamp` timestamp NOT NULL, | ||
13 | PRIMARY KEY (`SessionID`), | ||
14 | KEY (`UserID`) | ||
15 | ) ENGINE=InnoDB; | ||
16 | |||
17 | COMMIT; | ||
18 | |||
diff --git a/OpenSim/Data/MySQL/Resources/UserProfiles.migrations b/OpenSim/Data/MySQL/Resources/UserProfiles.migrations new file mode 100644 index 0000000..c29f1ab --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/UserProfiles.migrations | |||
@@ -0,0 +1,83 @@ | |||
1 | :VERSION 1 # ------------------------------- | ||
2 | |||
3 | begin; | ||
4 | |||
5 | CREATE TABLE IF NOT EXISTS `classifieds` ( | ||
6 | `classifieduuid` char(36) NOT NULL, | ||
7 | `creatoruuid` char(36) NOT NULL, | ||
8 | `creationdate` int(20) NOT NULL, | ||
9 | `expirationdate` int(20) NOT NULL, | ||
10 | `category` varchar(20) NOT NULL, | ||
11 | `name` varchar(255) NOT NULL, | ||
12 | `description` text NOT NULL, | ||
13 | `parceluuid` char(36) NOT NULL, | ||
14 | `parentestate` int(11) NOT NULL, | ||
15 | `snapshotuuid` char(36) NOT NULL, | ||
16 | `simname` varchar(255) NOT NULL, | ||
17 | `posglobal` varchar(255) NOT NULL, | ||
18 | `parcelname` varchar(255) NOT NULL, | ||
19 | `classifiedflags` int(8) NOT NULL, | ||
20 | `priceforlisting` int(5) NOT NULL, | ||
21 | PRIMARY KEY (`classifieduuid`) | ||
22 | ) ENGINE=InnoDB DEFAULT CHARSET=latin1; | ||
23 | |||
24 | |||
25 | CREATE TABLE IF NOT EXISTS `usernotes` ( | ||
26 | `useruuid` varchar(36) NOT NULL, | ||
27 | `targetuuid` varchar(36) NOT NULL, | ||
28 | `notes` text NOT NULL, | ||
29 | UNIQUE KEY `useruuid` (`useruuid`,`targetuuid`) | ||
30 | ) ENGINE=MyISAM DEFAULT CHARSET=latin1; | ||
31 | |||
32 | |||
33 | CREATE TABLE IF NOT EXISTS `userpicks` ( | ||
34 | `pickuuid` varchar(36) NOT NULL, | ||
35 | `creatoruuid` varchar(36) NOT NULL, | ||
36 | `toppick` enum('true','false') NOT NULL, | ||
37 | `parceluuid` varchar(36) NOT NULL, | ||
38 | `name` varchar(255) NOT NULL, | ||
39 | `description` text NOT NULL, | ||
40 | `snapshotuuid` varchar(36) NOT NULL, | ||
41 | `user` varchar(255) NOT NULL, | ||
42 | `originalname` varchar(255) NOT NULL, | ||
43 | `simname` varchar(255) NOT NULL, | ||
44 | `posglobal` varchar(255) NOT NULL, | ||
45 | `sortorder` int(2) NOT NULL, | ||
46 | `enabled` enum('true','false') NOT NULL, | ||
47 | PRIMARY KEY (`pickuuid`) | ||
48 | ) ENGINE=MyISAM DEFAULT CHARSET=latin1; | ||
49 | |||
50 | |||
51 | CREATE TABLE IF NOT EXISTS `userprofile` ( | ||
52 | `useruuid` varchar(36) NOT NULL, | ||
53 | `profilePartner` varchar(36) NOT NULL, | ||
54 | `profileAllowPublish` binary(1) NOT NULL, | ||
55 | `profileMaturePublish` binary(1) NOT NULL, | ||
56 | `profileURL` varchar(255) NOT NULL, | ||
57 | `profileWantToMask` int(3) NOT NULL, | ||
58 | `profileWantToText` text NOT NULL, | ||
59 | `profileSkillsMask` int(3) NOT NULL, | ||
60 | `profileSkillsText` text NOT NULL, | ||
61 | `profileLanguages` text NOT NULL, | ||
62 | `profileImage` varchar(36) NOT NULL, | ||
63 | `profileAboutText` text NOT NULL, | ||
64 | `profileFirstImage` varchar(36) NOT NULL, | ||
65 | `profileFirstText` text NOT NULL, | ||
66 | PRIMARY KEY (`useruuid`) | ||
67 | ) ENGINE=MyISAM DEFAULT CHARSET=latin1; | ||
68 | |||
69 | commit; | ||
70 | |||
71 | :VERSION 2 # ------------------------------- | ||
72 | |||
73 | begin; | ||
74 | CREATE TABLE IF NOT EXISTS `userdata` ( | ||
75 | `UserId` char(36) NOT NULL, | ||
76 | `TagId` varchar(64) NOT NULL, | ||
77 | `DataKey` varchar(255), | ||
78 | `DataVal` varchar(255), | ||
79 | PRIMARY KEY (`UserId`,`TagId`) | ||
80 | ) ENGINE=MyISAM DEFAULT CHARSET=latin1; | ||
81 | |||
82 | commit; | ||
83 | |||
diff --git a/OpenSim/Data/Null/NullEstateData.cs b/OpenSim/Data/Null/NullEstateData.cs index d64136d..1df397d 100755 --- a/OpenSim/Data/Null/NullEstateData.cs +++ b/OpenSim/Data/Null/NullEstateData.cs | |||
@@ -42,6 +42,22 @@ namespace OpenSim.Data.Null | |||
42 | 42 | ||
43 | // private string m_connectionString; | 43 | // private string m_connectionString; |
44 | 44 | ||
45 | private Dictionary<uint, EstateSettings> m_knownEstates = new Dictionary<uint, EstateSettings>(); | ||
46 | private EstateSettings m_estate = null; | ||
47 | |||
48 | private EstateSettings GetEstate() | ||
49 | { | ||
50 | if (m_estate == null) | ||
51 | { | ||
52 | // This fools the initialization caller into thinking an estate was fetched (a check in OpenSimBase). | ||
53 | // The estate info is pretty empty so don't try banning anyone. | ||
54 | m_estate = new EstateSettings(); | ||
55 | m_estate.EstateID = 1; | ||
56 | m_estate.OnSave += StoreEstateSettings; | ||
57 | } | ||
58 | return m_estate; | ||
59 | } | ||
60 | |||
45 | protected virtual Assembly Assembly | 61 | protected virtual Assembly Assembly |
46 | { | 62 | { |
47 | get { return GetType().Assembly; } | 63 | get { return GetType().Assembly; } |
@@ -68,21 +84,18 @@ namespace OpenSim.Data.Null | |||
68 | 84 | ||
69 | public EstateSettings LoadEstateSettings(UUID regionID, bool create) | 85 | public EstateSettings LoadEstateSettings(UUID regionID, bool create) |
70 | { | 86 | { |
71 | // This fools the initialization caller into thinking an estate was fetched (a check in OpenSimBase). | 87 | return GetEstate(); |
72 | // The estate info is pretty empty so don't try banning anyone. | ||
73 | EstateSettings oneEstate = new EstateSettings(); | ||
74 | oneEstate.EstateID = 1; | ||
75 | return oneEstate; | ||
76 | } | 88 | } |
77 | 89 | ||
78 | public void StoreEstateSettings(EstateSettings es) | 90 | public void StoreEstateSettings(EstateSettings es) |
79 | { | 91 | { |
92 | m_estate = es; | ||
80 | return; | 93 | return; |
81 | } | 94 | } |
82 | 95 | ||
83 | public EstateSettings LoadEstateSettings(int estateID) | 96 | public EstateSettings LoadEstateSettings(int estateID) |
84 | { | 97 | { |
85 | return new EstateSettings(); | 98 | return GetEstate(); |
86 | } | 99 | } |
87 | 100 | ||
88 | public EstateSettings CreateNewEstate() | 101 | public EstateSettings CreateNewEstate() |
@@ -93,13 +106,14 @@ namespace OpenSim.Data.Null | |||
93 | public List<EstateSettings> LoadEstateSettingsAll() | 106 | public List<EstateSettings> LoadEstateSettingsAll() |
94 | { | 107 | { |
95 | List<EstateSettings> allEstateSettings = new List<EstateSettings>(); | 108 | List<EstateSettings> allEstateSettings = new List<EstateSettings>(); |
96 | allEstateSettings.Add(new EstateSettings()); | 109 | allEstateSettings.Add(GetEstate()); |
97 | return allEstateSettings; | 110 | return allEstateSettings; |
98 | } | 111 | } |
99 | 112 | ||
100 | public List<int> GetEstatesAll() | 113 | public List<int> GetEstatesAll() |
101 | { | 114 | { |
102 | List<int> result = new List<int>(); | 115 | List<int> result = new List<int>(); |
116 | result.Add((int)GetEstate().EstateID); | ||
103 | return result; | 117 | return result; |
104 | } | 118 | } |
105 | 119 | ||
diff --git a/OpenSim/Data/Null/NullRegionData.cs b/OpenSim/Data/Null/NullRegionData.cs index f707d98..d28cd99 100644 --- a/OpenSim/Data/Null/NullRegionData.cs +++ b/OpenSim/Data/Null/NullRegionData.cs | |||
@@ -239,6 +239,11 @@ namespace OpenSim.Data.Null | |||
239 | return Get((int)RegionFlags.DefaultRegion, scopeID); | 239 | return Get((int)RegionFlags.DefaultRegion, scopeID); |
240 | } | 240 | } |
241 | 241 | ||
242 | public List<RegionData> GetDefaultHypergridRegions(UUID scopeID) | ||
243 | { | ||
244 | return Get((int)RegionFlags.DefaultHGRegion, scopeID); | ||
245 | } | ||
246 | |||
242 | public List<RegionData> GetFallbackRegions(UUID scopeID, int x, int y) | 247 | public List<RegionData> GetFallbackRegions(UUID scopeID, int x, int y) |
243 | { | 248 | { |
244 | List<RegionData> regions = Get((int)RegionFlags.FallbackRegion, scopeID); | 249 | List<RegionData> regions = Get((int)RegionFlags.FallbackRegion, scopeID); |
diff --git a/OpenSim/Data/Null/NullSimulationData.cs b/OpenSim/Data/Null/NullSimulationData.cs index e7e5c41..15824a9 100644 --- a/OpenSim/Data/Null/NullSimulationData.cs +++ b/OpenSim/Data/Null/NullSimulationData.cs | |||
@@ -77,20 +77,34 @@ namespace OpenSim.Data.Null | |||
77 | } | 77 | } |
78 | 78 | ||
79 | #region Environment Settings | 79 | #region Environment Settings |
80 | |||
81 | private Dictionary<UUID, string> EnvironmentSettings = new Dictionary<UUID, string>(); | ||
82 | |||
80 | public string LoadRegionEnvironmentSettings(UUID regionUUID) | 83 | public string LoadRegionEnvironmentSettings(UUID regionUUID) |
81 | { | 84 | { |
82 | //This connector doesn't support the Environment module yet | 85 | lock (EnvironmentSettings) |
86 | { | ||
87 | if (EnvironmentSettings.ContainsKey(regionUUID)) | ||
88 | return EnvironmentSettings[regionUUID]; | ||
89 | } | ||
83 | return string.Empty; | 90 | return string.Empty; |
84 | } | 91 | } |
85 | 92 | ||
86 | public void StoreRegionEnvironmentSettings(UUID regionUUID, string settings) | 93 | public void StoreRegionEnvironmentSettings(UUID regionUUID, string settings) |
87 | { | 94 | { |
88 | //This connector doesn't support the Environment module yet | 95 | lock (EnvironmentSettings) |
96 | { | ||
97 | EnvironmentSettings[regionUUID] = settings; | ||
98 | } | ||
89 | } | 99 | } |
90 | 100 | ||
91 | public void RemoveRegionEnvironmentSettings(UUID regionUUID) | 101 | public void RemoveRegionEnvironmentSettings(UUID regionUUID) |
92 | { | 102 | { |
93 | //This connector doesn't support the Environment module yet | 103 | lock (EnvironmentSettings) |
104 | { | ||
105 | if (EnvironmentSettings.ContainsKey(regionUUID)) | ||
106 | EnvironmentSettings.Remove(regionUUID); | ||
107 | } | ||
94 | } | 108 | } |
95 | #endregion | 109 | #endregion |
96 | 110 | ||
diff --git a/OpenSim/Data/SQLite/Resources/EstateStore.migrations b/OpenSim/Data/SQLite/Resources/EstateStore.migrations index 62f6464..0aec49b 100644 --- a/OpenSim/Data/SQLite/Resources/EstateStore.migrations +++ b/OpenSim/Data/SQLite/Resources/EstateStore.migrations | |||
@@ -86,3 +86,12 @@ begin; | |||
86 | alter table estate_settings add column DenyMinors tinyint not null default 0; | 86 | alter table estate_settings add column DenyMinors tinyint not null default 0; |
87 | 87 | ||
88 | commit; | 88 | commit; |
89 | |||
90 | :VERSION 9 | ||
91 | |||
92 | begin; | ||
93 | alter table estate_settings add column AllowLandmark tinyint not null default '1'; | ||
94 | alter table estate_settings add column AllowParcelChanges tinyint not null default '1'; | ||
95 | alter table estate_settings add column AllowSetHome tinyint not null default '1'; | ||
96 | commit; | ||
97 | |||
diff --git a/OpenSim/Data/SQLite/Resources/HGTravelStore.migrations b/OpenSim/Data/SQLite/Resources/HGTravelStore.migrations new file mode 100644 index 0000000..02612ce --- /dev/null +++ b/OpenSim/Data/SQLite/Resources/HGTravelStore.migrations | |||
@@ -0,0 +1,18 @@ | |||
1 | :VERSION 2 # -------------------------- | ||
2 | |||
3 | BEGIN; | ||
4 | |||
5 | CREATE TABLE hg_traveling_data( | ||
6 | SessionID VARCHAR(36) NOT NULL, | ||
7 | UserID VARCHAR(36) NOT NULL, | ||
8 | GridExternalName VARCHAR(255) NOT NULL DEFAULT "", | ||
9 | ServiceToken VARCHAR(255) NOT NULL DEFAULT "", | ||
10 | ClientIPAddress VARCHAR(16) NOT NULL DEFAULT "", | ||
11 | MyIPAddress VARCHAR(16) NOT NULL DEFAULT "", | ||
12 | TMStamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP, | ||
13 | PRIMARY KEY(SessionID), | ||
14 | UNIQUE(UserID) | ||
15 | ); | ||
16 | |||
17 | COMMIT; | ||
18 | |||
diff --git a/OpenSim/Data/SQLite/Resources/RegionStore.migrations b/OpenSim/Data/SQLite/Resources/RegionStore.migrations index c6f4b48..bff039d 100644 --- a/OpenSim/Data/SQLite/Resources/RegionStore.migrations +++ b/OpenSim/Data/SQLite/Resources/RegionStore.migrations | |||
@@ -592,3 +592,11 @@ ALTER TABLE prims ADD COLUMN `Friction` double NOT NULL default '0.6'; | |||
592 | ALTER TABLE prims ADD COLUMN `Restitution` double NOT NULL default '0.5'; | 592 | ALTER TABLE prims ADD COLUMN `Restitution` double NOT NULL default '0.5'; |
593 | 593 | ||
594 | COMMIT; | 594 | COMMIT; |
595 | |||
596 | :VERSION 29 #---------------- Keyframes | ||
597 | |||
598 | BEGIN; | ||
599 | |||
600 | ALTER TABLE prims ADD COLUMN `KeyframeMotion` blob; | ||
601 | |||
602 | COMMIT; | ||
diff --git a/OpenSim/Data/SQLite/Resources/UserProfiles.migrations b/OpenSim/Data/SQLite/Resources/UserProfiles.migrations new file mode 100644 index 0000000..16581f6 --- /dev/null +++ b/OpenSim/Data/SQLite/Resources/UserProfiles.migrations | |||
@@ -0,0 +1,90 @@ | |||
1 | :VERSION 1 # ------------------------------- | ||
2 | |||
3 | begin; | ||
4 | |||
5 | CREATE TABLE IF NOT EXISTS classifieds ( | ||
6 | classifieduuid char(36) NOT NULL PRIMARY KEY, | ||
7 | creatoruuid char(36) NOT NULL, | ||
8 | creationdate int(20) NOT NULL, | ||
9 | expirationdate int(20) NOT NULL, | ||
10 | category varchar(20) NOT NULL, | ||
11 | name varchar(255) NOT NULL, | ||
12 | description text NOT NULL, | ||
13 | parceluuid char(36) NOT NULL, | ||
14 | parentestate int(11) NOT NULL, | ||
15 | snapshotuuid char(36) NOT NULL, | ||
16 | simname varchar(255) NOT NULL, | ||
17 | posglobal varchar(255) NOT NULL, | ||
18 | parcelname varchar(255) NOT NULL, | ||
19 | classifiedflags int(8) NOT NULL, | ||
20 | priceforlisting int(5) NOT NULL | ||
21 | ); | ||
22 | |||
23 | commit; | ||
24 | |||
25 | begin; | ||
26 | |||
27 | CREATE TABLE IF NOT EXISTS usernotes ( | ||
28 | useruuid varchar(36) NOT NULL, | ||
29 | targetuuid varchar(36) NOT NULL, | ||
30 | notes text NOT NULL, | ||
31 | UNIQUE (useruuid,targetuuid) ON CONFLICT REPLACE | ||
32 | ); | ||
33 | |||
34 | commit; | ||
35 | |||
36 | begin; | ||
37 | |||
38 | CREATE TABLE IF NOT EXISTS userpicks ( | ||
39 | pickuuid varchar(36) NOT NULL PRIMARY KEY, | ||
40 | creatoruuid varchar(36) NOT NULL, | ||
41 | toppick int NOT NULL, | ||
42 | parceluuid varchar(36) NOT NULL, | ||
43 | name varchar(255) NOT NULL, | ||
44 | description text NOT NULL, | ||
45 | snapshotuuid varchar(36) NOT NULL, | ||
46 | user varchar(255) NOT NULL, | ||
47 | originalname varchar(255) NOT NULL, | ||
48 | simname varchar(255) NOT NULL, | ||
49 | posglobal varchar(255) NOT NULL, | ||
50 | sortorder int(2) NOT NULL, | ||
51 | enabled int NOT NULL | ||
52 | ); | ||
53 | |||
54 | commit; | ||
55 | |||
56 | begin; | ||
57 | |||
58 | CREATE TABLE IF NOT EXISTS userprofile ( | ||
59 | useruuid varchar(36) NOT NULL PRIMARY KEY, | ||
60 | profilePartner varchar(36) NOT NULL, | ||
61 | profileAllowPublish binary(1) NOT NULL, | ||
62 | profileMaturePublish binary(1) NOT NULL, | ||
63 | profileURL varchar(255) NOT NULL, | ||
64 | profileWantToMask int(3) NOT NULL, | ||
65 | profileWantToText text NOT NULL, | ||
66 | profileSkillsMask int(3) NOT NULL, | ||
67 | profileSkillsText text NOT NULL, | ||
68 | profileLanguages text NOT NULL, | ||
69 | profileImage varchar(36) NOT NULL, | ||
70 | profileAboutText text NOT NULL, | ||
71 | profileFirstImage varchar(36) NOT NULL, | ||
72 | profileFirstText text NOT NULL | ||
73 | ); | ||
74 | |||
75 | commit; | ||
76 | |||
77 | :VERSION 2 # ------------------------------- | ||
78 | |||
79 | begin; | ||
80 | |||
81 | CREATE TABLE IF NOT EXISTS userdata ( | ||
82 | UserId char(36) NOT NULL, | ||
83 | TagId varchar(64) NOT NULL, | ||
84 | DataKey varchar(255), | ||
85 | DataVal varchar(255), | ||
86 | PRIMARY KEY (UserId,TagId) | ||
87 | ); | ||
88 | |||
89 | commit; | ||
90 | |||
diff --git a/OpenSim/Data/SQLite/SQLiteGridUserData.cs b/OpenSim/Data/SQLite/SQLiteGridUserData.cs index 1bb5ed8..d8c52f8 100644 --- a/OpenSim/Data/SQLite/SQLiteGridUserData.cs +++ b/OpenSim/Data/SQLite/SQLiteGridUserData.cs | |||
@@ -56,6 +56,10 @@ namespace OpenSim.Data.SQLite | |||
56 | return ret[0]; | 56 | return ret[0]; |
57 | } | 57 | } |
58 | 58 | ||
59 | public GridUserData[] GetAll(string userID) | ||
60 | { | ||
61 | return base.Get(String.Format("UserID LIKE '{0}%'", userID)); | ||
62 | } | ||
59 | 63 | ||
60 | } | 64 | } |
61 | } \ No newline at end of file | 65 | } \ No newline at end of file |
diff --git a/OpenSim/Data/SQLite/SQLiteHGTravelData.cs b/OpenSim/Data/SQLite/SQLiteHGTravelData.cs new file mode 100644 index 0000000..db288b2 --- /dev/null +++ b/OpenSim/Data/SQLite/SQLiteHGTravelData.cs | |||
@@ -0,0 +1,82 @@ | |||
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 OpenMetaverse; | ||
35 | using OpenSim.Framework; | ||
36 | using Mono.Data.Sqlite; | ||
37 | |||
38 | namespace OpenSim.Data.SQLite | ||
39 | { | ||
40 | /// <summary> | ||
41 | /// A SQL Interface for user grid data | ||
42 | /// </summary> | ||
43 | public class SQLiteHGTravelData : SQLiteGenericTableHandler<HGTravelingData>, IHGTravelingData | ||
44 | { | ||
45 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
46 | |||
47 | public SQLiteHGTravelData(string connectionString, string realm) | ||
48 | : base(connectionString, realm, "HGTravelStore") {} | ||
49 | |||
50 | public HGTravelingData Get(UUID sessionID) | ||
51 | { | ||
52 | HGTravelingData[] ret = Get("SessionID", sessionID.ToString()); | ||
53 | |||
54 | if (ret.Length == 0) | ||
55 | return null; | ||
56 | |||
57 | return ret[0]; | ||
58 | } | ||
59 | |||
60 | public HGTravelingData[] GetSessions(UUID userID) | ||
61 | { | ||
62 | return base.Get("UserID", userID.ToString()); | ||
63 | } | ||
64 | |||
65 | public bool Delete(UUID sessionID) | ||
66 | { | ||
67 | return Delete("SessionID", sessionID.ToString()); | ||
68 | } | ||
69 | |||
70 | public void DeleteOld() | ||
71 | { | ||
72 | using (SqliteCommand cmd = new SqliteCommand()) | ||
73 | { | ||
74 | cmd.CommandText = String.Format("delete from {0} where TMStamp < datetime('now', '-2 day') ", m_Realm); | ||
75 | |||
76 | DoQuery(cmd); | ||
77 | } | ||
78 | |||
79 | } | ||
80 | |||
81 | } | ||
82 | } \ No newline at end of file | ||
diff --git a/OpenSim/Data/SQLite/SQLiteSimulationData.cs b/OpenSim/Data/SQLite/SQLiteSimulationData.cs index 76f717d..52502b3 100644 --- a/OpenSim/Data/SQLite/SQLiteSimulationData.cs +++ b/OpenSim/Data/SQLite/SQLiteSimulationData.cs | |||
@@ -1244,6 +1244,7 @@ namespace OpenSim.Data.SQLite | |||
1244 | createCol(prims, "Friction", typeof(Double)); | 1244 | createCol(prims, "Friction", typeof(Double)); |
1245 | createCol(prims, "Restitution", typeof(Double)); | 1245 | createCol(prims, "Restitution", typeof(Double)); |
1246 | 1246 | ||
1247 | createCol(prims, "KeyframeMotion", typeof(Byte[])); | ||
1247 | // Add in contraints | 1248 | // Add in contraints |
1248 | prims.PrimaryKey = new DataColumn[] { prims.Columns["UUID"] }; | 1249 | prims.PrimaryKey = new DataColumn[] { prims.Columns["UUID"] }; |
1249 | 1250 | ||
@@ -1739,6 +1740,20 @@ namespace OpenSim.Data.SQLite | |||
1739 | prim.Friction = Convert.ToSingle(row["Friction"]); | 1740 | prim.Friction = Convert.ToSingle(row["Friction"]); |
1740 | prim.Restitution = Convert.ToSingle(row["Restitution"]); | 1741 | prim.Restitution = Convert.ToSingle(row["Restitution"]); |
1741 | 1742 | ||
1743 | |||
1744 | if (!(row["KeyframeMotion"] is DBNull)) | ||
1745 | { | ||
1746 | Byte[] data = (byte[])row["KeyframeMotion"]; | ||
1747 | if (data.Length > 0) | ||
1748 | prim.KeyframeMotion = KeyframeMotion.FromData(null, data); | ||
1749 | else | ||
1750 | prim.KeyframeMotion = null; | ||
1751 | } | ||
1752 | else | ||
1753 | { | ||
1754 | prim.KeyframeMotion = null; | ||
1755 | } | ||
1756 | |||
1742 | return prim; | 1757 | return prim; |
1743 | } | 1758 | } |
1744 | 1759 | ||
@@ -2161,7 +2176,7 @@ namespace OpenSim.Data.SQLite | |||
2161 | 2176 | ||
2162 | row["MediaURL"] = prim.MediaUrl; | 2177 | row["MediaURL"] = prim.MediaUrl; |
2163 | 2178 | ||
2164 | if (prim.DynAttrs.Count > 0) | 2179 | if (prim.DynAttrs.CountNamespaces > 0) |
2165 | row["DynAttrs"] = prim.DynAttrs.ToXml(); | 2180 | row["DynAttrs"] = prim.DynAttrs.ToXml(); |
2166 | else | 2181 | else |
2167 | row["DynAttrs"] = null; | 2182 | row["DynAttrs"] = null; |
@@ -2171,6 +2186,13 @@ namespace OpenSim.Data.SQLite | |||
2171 | row["GravityModifier"] = (double)prim.GravityModifier; | 2186 | row["GravityModifier"] = (double)prim.GravityModifier; |
2172 | row["Friction"] = (double)prim.Friction; | 2187 | row["Friction"] = (double)prim.Friction; |
2173 | row["Restitution"] = (double)prim.Restitution; | 2188 | row["Restitution"] = (double)prim.Restitution; |
2189 | |||
2190 | if (prim.KeyframeMotion != null) | ||
2191 | row["KeyframeMotion"] = prim.KeyframeMotion.Serialize(); | ||
2192 | else | ||
2193 | row["KeyframeMotion"] = new Byte[0]; | ||
2194 | |||
2195 | |||
2174 | } | 2196 | } |
2175 | 2197 | ||
2176 | /// <summary> | 2198 | /// <summary> |
diff --git a/OpenSim/Data/SQLite/SQLiteUserProfilesData.cs b/OpenSim/Data/SQLite/SQLiteUserProfilesData.cs new file mode 100644 index 0000000..cc1dac1 --- /dev/null +++ b/OpenSim/Data/SQLite/SQLiteUserProfilesData.cs | |||
@@ -0,0 +1,904 @@ | |||
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 | #if CSharpSqlite | ||
34 | using Community.CsharpSqlite.Sqlite; | ||
35 | #else | ||
36 | using Mono.Data.Sqlite; | ||
37 | #endif | ||
38 | using OpenMetaverse; | ||
39 | using OpenMetaverse.StructuredData; | ||
40 | using OpenSim.Framework; | ||
41 | using OpenSim.Region.Framework.Interfaces; | ||
42 | |||
43 | namespace OpenSim.Data.SQLite | ||
44 | { | ||
45 | public class SQLiteUserProfilesData: IProfilesData | ||
46 | { | ||
47 | private static readonly ILog m_log = | ||
48 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
49 | |||
50 | private SqliteConnection m_connection; | ||
51 | private string m_connectionString; | ||
52 | |||
53 | private FieldInfo[] m_Fields; | ||
54 | private Dictionary<string, FieldInfo> m_FieldMap = | ||
55 | new Dictionary<string, FieldInfo>(); | ||
56 | |||
57 | protected virtual Assembly Assembly | ||
58 | { | ||
59 | get { return GetType().Assembly; } | ||
60 | } | ||
61 | |||
62 | public SQLiteUserProfilesData() | ||
63 | { | ||
64 | } | ||
65 | |||
66 | public SQLiteUserProfilesData(string connectionString) | ||
67 | { | ||
68 | Initialise(connectionString); | ||
69 | } | ||
70 | |||
71 | public void Initialise(string connectionString) | ||
72 | { | ||
73 | if (Util.IsWindows()) | ||
74 | Util.LoadArchSpecificWindowsDll("sqlite3.dll"); | ||
75 | |||
76 | m_connectionString = connectionString; | ||
77 | |||
78 | m_log.Info("[PROFILES_DATA]: Sqlite - connecting: "+m_connectionString); | ||
79 | |||
80 | m_connection = new SqliteConnection(m_connectionString); | ||
81 | m_connection.Open(); | ||
82 | |||
83 | Migration m = new Migration(m_connection, Assembly, "UserProfiles"); | ||
84 | m.Update(); | ||
85 | } | ||
86 | |||
87 | private string[] FieldList | ||
88 | { | ||
89 | get { return new List<string>(m_FieldMap.Keys).ToArray(); } | ||
90 | } | ||
91 | |||
92 | #region IProfilesData implementation | ||
93 | public OSDArray GetClassifiedRecords(UUID creatorId) | ||
94 | { | ||
95 | OSDArray data = new OSDArray(); | ||
96 | string query = "SELECT classifieduuid, name FROM classifieds WHERE creatoruuid = :Id"; | ||
97 | IDataReader reader = null; | ||
98 | |||
99 | using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) | ||
100 | { | ||
101 | cmd.CommandText = query; | ||
102 | cmd.Parameters.AddWithValue(":Id", creatorId); | ||
103 | reader = cmd.ExecuteReader(); | ||
104 | } | ||
105 | |||
106 | while (reader.Read()) | ||
107 | { | ||
108 | OSDMap n = new OSDMap(); | ||
109 | UUID Id = UUID.Zero; | ||
110 | string Name = null; | ||
111 | try | ||
112 | { | ||
113 | UUID.TryParse(Convert.ToString( reader["classifieduuid"]), out Id); | ||
114 | Name = Convert.ToString(reader["name"]); | ||
115 | } | ||
116 | catch (Exception e) | ||
117 | { | ||
118 | m_log.DebugFormat("[PROFILES_DATA]" + | ||
119 | ": UserAccount exception {0}", e.Message); | ||
120 | } | ||
121 | n.Add("classifieduuid", OSD.FromUUID(Id)); | ||
122 | n.Add("name", OSD.FromString(Name)); | ||
123 | data.Add(n); | ||
124 | } | ||
125 | |||
126 | reader.Close(); | ||
127 | |||
128 | return data; | ||
129 | } | ||
130 | public bool UpdateClassifiedRecord(UserClassifiedAdd ad, ref string result) | ||
131 | { | ||
132 | string query = string.Empty; | ||
133 | |||
134 | query += "INSERT OR REPLACE INTO classifieds ("; | ||
135 | query += "`classifieduuid`,"; | ||
136 | query += "`creatoruuid`,"; | ||
137 | query += "`creationdate`,"; | ||
138 | query += "`expirationdate`,"; | ||
139 | query += "`category`,"; | ||
140 | query += "`name`,"; | ||
141 | query += "`description`,"; | ||
142 | query += "`parceluuid`,"; | ||
143 | query += "`parentestate`,"; | ||
144 | query += "`snapshotuuid`,"; | ||
145 | query += "`simname`,"; | ||
146 | query += "`posglobal`,"; | ||
147 | query += "`parcelname`,"; | ||
148 | query += "`classifiedflags`,"; | ||
149 | query += "`priceforlisting`) "; | ||
150 | query += "VALUES ("; | ||
151 | query += ":ClassifiedId,"; | ||
152 | query += ":CreatorId,"; | ||
153 | query += ":CreatedDate,"; | ||
154 | query += ":ExpirationDate,"; | ||
155 | query += ":Category,"; | ||
156 | query += ":Name,"; | ||
157 | query += ":Description,"; | ||
158 | query += ":ParcelId,"; | ||
159 | query += ":ParentEstate,"; | ||
160 | query += ":SnapshotId,"; | ||
161 | query += ":SimName,"; | ||
162 | query += ":GlobalPos,"; | ||
163 | query += ":ParcelName,"; | ||
164 | query += ":Flags,"; | ||
165 | query += ":ListingPrice ) "; | ||
166 | |||
167 | if(string.IsNullOrEmpty(ad.ParcelName)) | ||
168 | ad.ParcelName = "Unknown"; | ||
169 | if(ad.ParcelId == null) | ||
170 | ad.ParcelId = UUID.Zero; | ||
171 | if(string.IsNullOrEmpty(ad.Description)) | ||
172 | ad.Description = "No Description"; | ||
173 | |||
174 | DateTime epoch = new DateTime(1970, 1, 1); | ||
175 | DateTime now = DateTime.Now; | ||
176 | TimeSpan epochnow = now - epoch; | ||
177 | TimeSpan duration; | ||
178 | DateTime expiration; | ||
179 | TimeSpan epochexp; | ||
180 | |||
181 | if(ad.Flags == 2) | ||
182 | { | ||
183 | duration = new TimeSpan(7,0,0,0); | ||
184 | expiration = now.Add(duration); | ||
185 | epochexp = expiration - epoch; | ||
186 | } | ||
187 | else | ||
188 | { | ||
189 | duration = new TimeSpan(365,0,0,0); | ||
190 | expiration = now.Add(duration); | ||
191 | epochexp = expiration - epoch; | ||
192 | } | ||
193 | ad.CreationDate = (int)epochnow.TotalSeconds; | ||
194 | ad.ExpirationDate = (int)epochexp.TotalSeconds; | ||
195 | |||
196 | try { | ||
197 | using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) | ||
198 | { | ||
199 | cmd.CommandText = query; | ||
200 | cmd.Parameters.AddWithValue(":ClassifiedId", ad.ClassifiedId.ToString()); | ||
201 | cmd.Parameters.AddWithValue(":CreatorId", ad.CreatorId.ToString()); | ||
202 | cmd.Parameters.AddWithValue(":CreatedDate", ad.CreationDate.ToString()); | ||
203 | cmd.Parameters.AddWithValue(":ExpirationDate", ad.ExpirationDate.ToString()); | ||
204 | cmd.Parameters.AddWithValue(":Category", ad.Category.ToString()); | ||
205 | cmd.Parameters.AddWithValue(":Name", ad.Name.ToString()); | ||
206 | cmd.Parameters.AddWithValue(":Description", ad.Description.ToString()); | ||
207 | cmd.Parameters.AddWithValue(":ParcelId", ad.ParcelId.ToString()); | ||
208 | cmd.Parameters.AddWithValue(":ParentEstate", ad.ParentEstate.ToString()); | ||
209 | cmd.Parameters.AddWithValue(":SnapshotId", ad.SnapshotId.ToString ()); | ||
210 | cmd.Parameters.AddWithValue(":SimName", ad.SimName.ToString()); | ||
211 | cmd.Parameters.AddWithValue(":GlobalPos", ad.GlobalPos.ToString()); | ||
212 | cmd.Parameters.AddWithValue(":ParcelName", ad.ParcelName.ToString()); | ||
213 | cmd.Parameters.AddWithValue(":Flags", ad.Flags.ToString()); | ||
214 | cmd.Parameters.AddWithValue(":ListingPrice", ad.Price.ToString ()); | ||
215 | |||
216 | cmd.ExecuteNonQuery(); | ||
217 | } | ||
218 | } | ||
219 | catch (Exception e) | ||
220 | { | ||
221 | m_log.DebugFormat("[PROFILES_DATA]" + | ||
222 | ": ClassifiedesUpdate exception {0}", e.Message); | ||
223 | result = e.Message; | ||
224 | return false; | ||
225 | } | ||
226 | return true; | ||
227 | } | ||
228 | public bool DeleteClassifiedRecord(UUID recordId) | ||
229 | { | ||
230 | string query = string.Empty; | ||
231 | |||
232 | query += "DELETE FROM classifieds WHERE "; | ||
233 | query += "classifieduuid = :ClasifiedId"; | ||
234 | |||
235 | try | ||
236 | { | ||
237 | using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) | ||
238 | { | ||
239 | cmd.CommandText = query; | ||
240 | cmd.Parameters.AddWithValue(":ClassifiedId", recordId.ToString()); | ||
241 | |||
242 | cmd.ExecuteNonQuery(); | ||
243 | } | ||
244 | } | ||
245 | catch (Exception e) | ||
246 | { | ||
247 | m_log.DebugFormat("[PROFILES_DATA]" + | ||
248 | ": DeleteClassifiedRecord exception {0}", e.Message); | ||
249 | return false; | ||
250 | } | ||
251 | return true; | ||
252 | } | ||
253 | |||
254 | public bool GetClassifiedInfo(ref UserClassifiedAdd ad, ref string result) | ||
255 | { | ||
256 | IDataReader reader = null; | ||
257 | string query = string.Empty; | ||
258 | |||
259 | query += "SELECT * FROM classifieds WHERE "; | ||
260 | query += "classifieduuid = :AdId"; | ||
261 | |||
262 | try | ||
263 | { | ||
264 | using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) | ||
265 | { | ||
266 | cmd.CommandText = query; | ||
267 | cmd.Parameters.AddWithValue(":AdId", ad.ClassifiedId.ToString()); | ||
268 | |||
269 | using (reader = cmd.ExecuteReader()) | ||
270 | { | ||
271 | if(reader.Read ()) | ||
272 | { | ||
273 | ad.CreatorId = new UUID(reader["creatoruuid"].ToString()); | ||
274 | ad.ParcelId = new UUID(reader["parceluuid"].ToString ()); | ||
275 | ad.SnapshotId = new UUID(reader["snapshotuuid"].ToString ()); | ||
276 | ad.CreationDate = Convert.ToInt32(reader["creationdate"]); | ||
277 | ad.ExpirationDate = Convert.ToInt32(reader["expirationdate"]); | ||
278 | ad.ParentEstate = Convert.ToInt32(reader["parentestate"]); | ||
279 | ad.Flags = (byte) Convert.ToUInt32(reader["classifiedflags"]); | ||
280 | ad.Category = Convert.ToInt32(reader["category"]); | ||
281 | ad.Price = Convert.ToInt16(reader["priceforlisting"]); | ||
282 | ad.Name = reader["name"].ToString(); | ||
283 | ad.Description = reader["description"].ToString(); | ||
284 | ad.SimName = reader["simname"].ToString(); | ||
285 | ad.GlobalPos = reader["posglobal"].ToString(); | ||
286 | ad.ParcelName = reader["parcelname"].ToString(); | ||
287 | } | ||
288 | } | ||
289 | } | ||
290 | } | ||
291 | catch (Exception e) | ||
292 | { | ||
293 | m_log.DebugFormat("[PROFILES_DATA]" + | ||
294 | ": GetPickInfo exception {0}", e.Message); | ||
295 | } | ||
296 | return true; | ||
297 | } | ||
298 | |||
299 | public OSDArray GetAvatarPicks(UUID avatarId) | ||
300 | { | ||
301 | IDataReader reader = null; | ||
302 | string query = string.Empty; | ||
303 | |||
304 | query += "SELECT `pickuuid`,`name` FROM userpicks WHERE "; | ||
305 | query += "creatoruuid = :Id"; | ||
306 | OSDArray data = new OSDArray(); | ||
307 | |||
308 | try | ||
309 | { | ||
310 | using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) | ||
311 | { | ||
312 | cmd.CommandText = query; | ||
313 | cmd.Parameters.AddWithValue(":Id", avatarId.ToString()); | ||
314 | |||
315 | using (reader = cmd.ExecuteReader()) | ||
316 | { | ||
317 | while (reader.Read()) | ||
318 | { | ||
319 | OSDMap record = new OSDMap(); | ||
320 | |||
321 | record.Add("pickuuid",OSD.FromString((string)reader["pickuuid"])); | ||
322 | record.Add("name",OSD.FromString((string)reader["name"])); | ||
323 | data.Add(record); | ||
324 | } | ||
325 | } | ||
326 | } | ||
327 | } | ||
328 | catch (Exception e) | ||
329 | { | ||
330 | m_log.DebugFormat("[PROFILES_DATA]" + | ||
331 | ": GetAvatarPicks exception {0}", e.Message); | ||
332 | } | ||
333 | return data; | ||
334 | } | ||
335 | public UserProfilePick GetPickInfo(UUID avatarId, UUID pickId) | ||
336 | { | ||
337 | IDataReader reader = null; | ||
338 | string query = string.Empty; | ||
339 | UserProfilePick pick = new UserProfilePick(); | ||
340 | |||
341 | query += "SELECT * FROM userpicks WHERE "; | ||
342 | query += "creatoruuid = :CreatorId AND "; | ||
343 | query += "pickuuid = :PickId"; | ||
344 | |||
345 | try | ||
346 | { | ||
347 | using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) | ||
348 | { | ||
349 | cmd.CommandText = query; | ||
350 | cmd.Parameters.AddWithValue(":CreatorId", avatarId.ToString()); | ||
351 | cmd.Parameters.AddWithValue(":PickId", pickId.ToString()); | ||
352 | |||
353 | using (reader = cmd.ExecuteReader()) | ||
354 | { | ||
355 | |||
356 | while (reader.Read()) | ||
357 | { | ||
358 | string description = (string)reader["description"]; | ||
359 | |||
360 | if (string.IsNullOrEmpty(description)) | ||
361 | description = "No description given."; | ||
362 | |||
363 | UUID.TryParse((string)reader["pickuuid"], out pick.PickId); | ||
364 | UUID.TryParse((string)reader["creatoruuid"], out pick.CreatorId); | ||
365 | UUID.TryParse((string)reader["parceluuid"], out pick.ParcelId); | ||
366 | UUID.TryParse((string)reader["snapshotuuid"], out pick.SnapshotId); | ||
367 | pick.GlobalPos = (string)reader["posglobal"]; | ||
368 | bool.TryParse((string)reader["toppick"].ToString(), out pick.TopPick); | ||
369 | bool.TryParse((string)reader["enabled"].ToString(), out pick.Enabled); | ||
370 | pick.Name = (string)reader["name"]; | ||
371 | pick.Desc = description; | ||
372 | pick.User = (string)reader["user"]; | ||
373 | pick.OriginalName = (string)reader["originalname"]; | ||
374 | pick.SimName = (string)reader["simname"]; | ||
375 | pick.SortOrder = (int)reader["sortorder"]; | ||
376 | } | ||
377 | } | ||
378 | } | ||
379 | } | ||
380 | catch (Exception e) | ||
381 | { | ||
382 | m_log.DebugFormat("[PROFILES_DATA]" + | ||
383 | ": GetPickInfo exception {0}", e.Message); | ||
384 | } | ||
385 | return pick; | ||
386 | } | ||
387 | |||
388 | public bool UpdatePicksRecord(UserProfilePick pick) | ||
389 | { | ||
390 | string query = string.Empty; | ||
391 | |||
392 | query += "INSERT OR REPLACE INTO userpicks ("; | ||
393 | query += "pickuuid, "; | ||
394 | query += "creatoruuid, "; | ||
395 | query += "toppick, "; | ||
396 | query += "parceluuid, "; | ||
397 | query += "name, "; | ||
398 | query += "description, "; | ||
399 | query += "snapshotuuid, "; | ||
400 | query += "user, "; | ||
401 | query += "originalname, "; | ||
402 | query += "simname, "; | ||
403 | query += "posglobal, "; | ||
404 | query += "sortorder, "; | ||
405 | query += "enabled ) "; | ||
406 | query += "VALUES ("; | ||
407 | query += ":PickId,"; | ||
408 | query += ":CreatorId,"; | ||
409 | query += ":TopPick,"; | ||
410 | query += ":ParcelId,"; | ||
411 | query += ":Name,"; | ||
412 | query += ":Desc,"; | ||
413 | query += ":SnapshotId,"; | ||
414 | query += ":User,"; | ||
415 | query += ":Original,"; | ||
416 | query += ":SimName,"; | ||
417 | query += ":GlobalPos,"; | ||
418 | query += ":SortOrder,"; | ||
419 | query += ":Enabled) "; | ||
420 | |||
421 | try | ||
422 | { | ||
423 | using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) | ||
424 | { | ||
425 | int top_pick; | ||
426 | int.TryParse(pick.TopPick.ToString(), out top_pick); | ||
427 | int enabled; | ||
428 | int.TryParse(pick.Enabled.ToString(), out enabled); | ||
429 | |||
430 | cmd.CommandText = query; | ||
431 | cmd.Parameters.AddWithValue(":PickId", pick.PickId.ToString()); | ||
432 | cmd.Parameters.AddWithValue(":CreatorId", pick.CreatorId.ToString()); | ||
433 | cmd.Parameters.AddWithValue(":TopPick", top_pick); | ||
434 | cmd.Parameters.AddWithValue(":ParcelId", pick.ParcelId.ToString()); | ||
435 | cmd.Parameters.AddWithValue(":Name", pick.Name.ToString()); | ||
436 | cmd.Parameters.AddWithValue(":Desc", pick.Desc.ToString()); | ||
437 | cmd.Parameters.AddWithValue(":SnapshotId", pick.SnapshotId.ToString()); | ||
438 | cmd.Parameters.AddWithValue(":User", pick.User.ToString()); | ||
439 | cmd.Parameters.AddWithValue(":Original", pick.OriginalName.ToString()); | ||
440 | cmd.Parameters.AddWithValue(":SimName",pick.SimName.ToString()); | ||
441 | cmd.Parameters.AddWithValue(":GlobalPos", pick.GlobalPos); | ||
442 | cmd.Parameters.AddWithValue(":SortOrder", pick.SortOrder.ToString ()); | ||
443 | cmd.Parameters.AddWithValue(":Enabled", enabled); | ||
444 | |||
445 | cmd.ExecuteNonQuery(); | ||
446 | } | ||
447 | } | ||
448 | catch (Exception e) | ||
449 | { | ||
450 | m_log.DebugFormat("[PROFILES_DATA]" + | ||
451 | ": UpdateAvatarNotes exception {0}", e.Message); | ||
452 | return false; | ||
453 | } | ||
454 | return true; | ||
455 | } | ||
456 | |||
457 | public bool DeletePicksRecord(UUID pickId) | ||
458 | { | ||
459 | string query = string.Empty; | ||
460 | |||
461 | query += "DELETE FROM userpicks WHERE "; | ||
462 | query += "pickuuid = :PickId"; | ||
463 | |||
464 | try | ||
465 | { | ||
466 | using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) | ||
467 | { | ||
468 | cmd.CommandText = query; | ||
469 | cmd.Parameters.AddWithValue(":PickId", pickId.ToString()); | ||
470 | cmd.ExecuteNonQuery(); | ||
471 | } | ||
472 | } | ||
473 | catch (Exception e) | ||
474 | { | ||
475 | m_log.DebugFormat("[PROFILES_DATA]" + | ||
476 | ": DeleteUserPickRecord exception {0}", e.Message); | ||
477 | return false; | ||
478 | } | ||
479 | return true; | ||
480 | } | ||
481 | |||
482 | public bool GetAvatarNotes(ref UserProfileNotes notes) | ||
483 | { | ||
484 | IDataReader reader = null; | ||
485 | string query = string.Empty; | ||
486 | |||
487 | query += "SELECT `notes` FROM usernotes WHERE "; | ||
488 | query += "useruuid = :Id AND "; | ||
489 | query += "targetuuid = :TargetId"; | ||
490 | OSDArray data = new OSDArray(); | ||
491 | |||
492 | try | ||
493 | { | ||
494 | using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) | ||
495 | { | ||
496 | cmd.CommandText = query; | ||
497 | cmd.Parameters.AddWithValue(":Id", notes.UserId.ToString()); | ||
498 | cmd.Parameters.AddWithValue(":TargetId", notes.TargetId.ToString()); | ||
499 | |||
500 | using (reader = cmd.ExecuteReader(CommandBehavior.SingleRow)) | ||
501 | { | ||
502 | while (reader.Read()) | ||
503 | { | ||
504 | notes.Notes = OSD.FromString((string)reader["notes"]); | ||
505 | } | ||
506 | } | ||
507 | } | ||
508 | } | ||
509 | catch (Exception e) | ||
510 | { | ||
511 | m_log.DebugFormat("[PROFILES_DATA]" + | ||
512 | ": GetAvatarNotes exception {0}", e.Message); | ||
513 | } | ||
514 | return true; | ||
515 | } | ||
516 | |||
517 | public bool UpdateAvatarNotes(ref UserProfileNotes note, ref string result) | ||
518 | { | ||
519 | string query = string.Empty; | ||
520 | bool remove; | ||
521 | |||
522 | if(string.IsNullOrEmpty(note.Notes)) | ||
523 | { | ||
524 | remove = true; | ||
525 | query += "DELETE FROM usernotes WHERE "; | ||
526 | query += "useruuid=:UserId AND "; | ||
527 | query += "targetuuid=:TargetId"; | ||
528 | } | ||
529 | else | ||
530 | { | ||
531 | remove = false; | ||
532 | query += "INSERT OR REPLACE INTO usernotes VALUES ( "; | ||
533 | query += ":UserId,"; | ||
534 | query += ":TargetId,"; | ||
535 | query += ":Notes )"; | ||
536 | } | ||
537 | |||
538 | try | ||
539 | { | ||
540 | using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) | ||
541 | { | ||
542 | cmd.CommandText = query; | ||
543 | |||
544 | if(!remove) | ||
545 | cmd.Parameters.AddWithValue(":Notes", note.Notes); | ||
546 | cmd.Parameters.AddWithValue(":TargetId", note.TargetId.ToString ()); | ||
547 | cmd.Parameters.AddWithValue(":UserId", note.UserId.ToString()); | ||
548 | |||
549 | cmd.ExecuteNonQuery(); | ||
550 | } | ||
551 | } | ||
552 | catch (Exception e) | ||
553 | { | ||
554 | m_log.DebugFormat("[PROFILES_DATA]" + | ||
555 | ": UpdateAvatarNotes exception {0}", e.Message); | ||
556 | return false; | ||
557 | } | ||
558 | return true; | ||
559 | } | ||
560 | |||
561 | public bool GetAvatarProperties(ref UserProfileProperties props, ref string result) | ||
562 | { | ||
563 | IDataReader reader = null; | ||
564 | string query = string.Empty; | ||
565 | |||
566 | query += "SELECT * FROM userprofile WHERE "; | ||
567 | query += "useruuid = :Id"; | ||
568 | |||
569 | using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) | ||
570 | { | ||
571 | cmd.CommandText = query; | ||
572 | cmd.Parameters.AddWithValue(":Id", props.UserId.ToString()); | ||
573 | |||
574 | |||
575 | try | ||
576 | { | ||
577 | reader = cmd.ExecuteReader(); | ||
578 | } | ||
579 | catch(Exception e) | ||
580 | { | ||
581 | m_log.DebugFormat("[PROFILES_DATA]" + | ||
582 | ": GetAvatarProperties exception {0}", e.Message); | ||
583 | result = e.Message; | ||
584 | return false; | ||
585 | } | ||
586 | if(reader != null && reader.Read()) | ||
587 | { | ||
588 | m_log.DebugFormat("[PROFILES_DATA]" + | ||
589 | ": Getting data for {0}.", props.UserId); | ||
590 | |||
591 | props.WebUrl = (string)reader["profileURL"]; | ||
592 | UUID.TryParse((string)reader["profileImage"], out props.ImageId); | ||
593 | props.AboutText = (string)reader["profileAboutText"]; | ||
594 | UUID.TryParse((string)reader["profileFirstImage"], out props.FirstLifeImageId); | ||
595 | props.FirstLifeText = (string)reader["profileFirstText"]; | ||
596 | UUID.TryParse((string)reader["profilePartner"], out props.PartnerId); | ||
597 | props.WantToMask = (int)reader["profileWantToMask"]; | ||
598 | props.WantToText = (string)reader["profileWantToText"]; | ||
599 | props.SkillsMask = (int)reader["profileSkillsMask"]; | ||
600 | props.SkillsText = (string)reader["profileSkillsText"]; | ||
601 | props.Language = (string)reader["profileLanguages"]; | ||
602 | } | ||
603 | else | ||
604 | { | ||
605 | m_log.DebugFormat("[PROFILES_DATA]" + | ||
606 | ": No data for {0}", props.UserId); | ||
607 | |||
608 | props.WebUrl = string.Empty; | ||
609 | props.ImageId = UUID.Zero; | ||
610 | props.AboutText = string.Empty; | ||
611 | props.FirstLifeImageId = UUID.Zero; | ||
612 | props.FirstLifeText = string.Empty; | ||
613 | props.PartnerId = UUID.Zero; | ||
614 | props.WantToMask = 0; | ||
615 | props.WantToText = string.Empty; | ||
616 | props.SkillsMask = 0; | ||
617 | props.SkillsText = string.Empty; | ||
618 | props.Language = string.Empty; | ||
619 | props.PublishProfile = false; | ||
620 | props.PublishMature = false; | ||
621 | |||
622 | query = "INSERT INTO userprofile ("; | ||
623 | query += "useruuid, "; | ||
624 | query += "profilePartner, "; | ||
625 | query += "profileAllowPublish, "; | ||
626 | query += "profileMaturePublish, "; | ||
627 | query += "profileURL, "; | ||
628 | query += "profileWantToMask, "; | ||
629 | query += "profileWantToText, "; | ||
630 | query += "profileSkillsMask, "; | ||
631 | query += "profileSkillsText, "; | ||
632 | query += "profileLanguages, "; | ||
633 | query += "profileImage, "; | ||
634 | query += "profileAboutText, "; | ||
635 | query += "profileFirstImage, "; | ||
636 | query += "profileFirstText) VALUES ("; | ||
637 | query += ":userId, "; | ||
638 | query += ":profilePartner, "; | ||
639 | query += ":profileAllowPublish, "; | ||
640 | query += ":profileMaturePublish, "; | ||
641 | query += ":profileURL, "; | ||
642 | query += ":profileWantToMask, "; | ||
643 | query += ":profileWantToText, "; | ||
644 | query += ":profileSkillsMask, "; | ||
645 | query += ":profileSkillsText, "; | ||
646 | query += ":profileLanguages, "; | ||
647 | query += ":profileImage, "; | ||
648 | query += ":profileAboutText, "; | ||
649 | query += ":profileFirstImage, "; | ||
650 | query += ":profileFirstText)"; | ||
651 | |||
652 | using (SqliteCommand put = (SqliteCommand)m_connection.CreateCommand()) | ||
653 | { | ||
654 | put.CommandText = query; | ||
655 | put.Parameters.AddWithValue(":userId", props.UserId.ToString()); | ||
656 | put.Parameters.AddWithValue(":profilePartner", props.PartnerId.ToString()); | ||
657 | put.Parameters.AddWithValue(":profileAllowPublish", props.PublishProfile); | ||
658 | put.Parameters.AddWithValue(":profileMaturePublish", props.PublishMature); | ||
659 | put.Parameters.AddWithValue(":profileURL", props.WebUrl); | ||
660 | put.Parameters.AddWithValue(":profileWantToMask", props.WantToMask); | ||
661 | put.Parameters.AddWithValue(":profileWantToText", props.WantToText); | ||
662 | put.Parameters.AddWithValue(":profileSkillsMask", props.SkillsMask); | ||
663 | put.Parameters.AddWithValue(":profileSkillsText", props.SkillsText); | ||
664 | put.Parameters.AddWithValue(":profileLanguages", props.Language); | ||
665 | put.Parameters.AddWithValue(":profileImage", props.ImageId.ToString()); | ||
666 | put.Parameters.AddWithValue(":profileAboutText", props.AboutText); | ||
667 | put.Parameters.AddWithValue(":profileFirstImage", props.FirstLifeImageId.ToString()); | ||
668 | put.Parameters.AddWithValue(":profileFirstText", props.FirstLifeText); | ||
669 | |||
670 | put.ExecuteNonQuery(); | ||
671 | } | ||
672 | } | ||
673 | } | ||
674 | return true; | ||
675 | } | ||
676 | |||
677 | public bool UpdateAvatarProperties(ref UserProfileProperties props, ref string result) | ||
678 | { | ||
679 | string query = string.Empty; | ||
680 | |||
681 | query += "UPDATE userprofile SET "; | ||
682 | query += "profilePartner=:profilePartner, "; | ||
683 | query += "profileURL=:profileURL, "; | ||
684 | query += "profileImage=:image, "; | ||
685 | query += "profileAboutText=:abouttext,"; | ||
686 | query += "profileFirstImage=:firstlifeimage,"; | ||
687 | query += "profileFirstText=:firstlifetext "; | ||
688 | query += "WHERE useruuid=:uuid"; | ||
689 | |||
690 | try | ||
691 | { | ||
692 | using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) | ||
693 | { | ||
694 | cmd.CommandText = query; | ||
695 | cmd.Parameters.AddWithValue(":profileURL", props.WebUrl); | ||
696 | cmd.Parameters.AddWithValue(":profilePartner", props.PartnerId.ToString()); | ||
697 | cmd.Parameters.AddWithValue(":image", props.ImageId.ToString()); | ||
698 | cmd.Parameters.AddWithValue(":abouttext", props.AboutText); | ||
699 | cmd.Parameters.AddWithValue(":firstlifeimage", props.FirstLifeImageId.ToString()); | ||
700 | cmd.Parameters.AddWithValue(":firstlifetext", props.FirstLifeText); | ||
701 | cmd.Parameters.AddWithValue(":uuid", props.UserId.ToString()); | ||
702 | |||
703 | cmd.ExecuteNonQuery(); | ||
704 | } | ||
705 | } | ||
706 | catch (Exception e) | ||
707 | { | ||
708 | m_log.DebugFormat("[PROFILES_DATA]" + | ||
709 | ": AgentPropertiesUpdate exception {0}", e.Message); | ||
710 | |||
711 | return false; | ||
712 | } | ||
713 | return true; | ||
714 | } | ||
715 | |||
716 | public bool UpdateAvatarInterests(UserProfileProperties up, ref string result) | ||
717 | { | ||
718 | string query = string.Empty; | ||
719 | |||
720 | query += "UPDATE userprofile SET "; | ||
721 | query += "profileWantToMask=:WantMask, "; | ||
722 | query += "profileWantToText=:WantText,"; | ||
723 | query += "profileSkillsMask=:SkillsMask,"; | ||
724 | query += "profileSkillsText=:SkillsText, "; | ||
725 | query += "profileLanguages=:Languages "; | ||
726 | query += "WHERE useruuid=:uuid"; | ||
727 | |||
728 | try | ||
729 | { | ||
730 | using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) | ||
731 | { | ||
732 | cmd.CommandText = query; | ||
733 | cmd.Parameters.AddWithValue(":WantMask", up.WantToMask); | ||
734 | cmd.Parameters.AddWithValue(":WantText", up.WantToText); | ||
735 | cmd.Parameters.AddWithValue(":SkillsMask", up.SkillsMask); | ||
736 | cmd.Parameters.AddWithValue(":SkillsText", up.SkillsText); | ||
737 | cmd.Parameters.AddWithValue(":Languages", up.Language); | ||
738 | cmd.Parameters.AddWithValue(":uuid", up.UserId.ToString()); | ||
739 | |||
740 | cmd.ExecuteNonQuery(); | ||
741 | } | ||
742 | } | ||
743 | catch (Exception e) | ||
744 | { | ||
745 | m_log.DebugFormat("[PROFILES_DATA]" + | ||
746 | ": AgentInterestsUpdate exception {0}", e.Message); | ||
747 | result = e.Message; | ||
748 | return false; | ||
749 | } | ||
750 | return true; | ||
751 | } | ||
752 | public bool GetUserAppData(ref UserAppData props, ref string result) | ||
753 | { | ||
754 | IDataReader reader = null; | ||
755 | string query = string.Empty; | ||
756 | |||
757 | query += "SELECT * FROM `userdata` WHERE "; | ||
758 | query += "UserId = :Id AND "; | ||
759 | query += "TagId = :TagId"; | ||
760 | |||
761 | try | ||
762 | { | ||
763 | using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) | ||
764 | { | ||
765 | cmd.CommandText = query; | ||
766 | cmd.Parameters.AddWithValue(":Id", props.UserId.ToString()); | ||
767 | cmd.Parameters.AddWithValue (":TagId", props.TagId.ToString()); | ||
768 | |||
769 | using (reader = cmd.ExecuteReader(CommandBehavior.SingleRow)) | ||
770 | { | ||
771 | if(reader.Read()) | ||
772 | { | ||
773 | props.DataKey = (string)reader["DataKey"]; | ||
774 | props.DataVal = (string)reader["DataVal"]; | ||
775 | } | ||
776 | else | ||
777 | { | ||
778 | query += "INSERT INTO userdata VALUES ( "; | ||
779 | query += ":UserId,"; | ||
780 | query += ":TagId,"; | ||
781 | query += ":DataKey,"; | ||
782 | query += ":DataVal) "; | ||
783 | |||
784 | using (SqliteCommand put = (SqliteCommand)m_connection.CreateCommand()) | ||
785 | { | ||
786 | put.Parameters.AddWithValue(":Id", props.UserId.ToString()); | ||
787 | put.Parameters.AddWithValue(":TagId", props.TagId.ToString()); | ||
788 | put.Parameters.AddWithValue(":DataKey", props.DataKey.ToString()); | ||
789 | put.Parameters.AddWithValue(":DataVal", props.DataVal.ToString()); | ||
790 | |||
791 | put.ExecuteNonQuery(); | ||
792 | } | ||
793 | } | ||
794 | } | ||
795 | } | ||
796 | } | ||
797 | catch (Exception e) | ||
798 | { | ||
799 | m_log.DebugFormat("[PROFILES_DATA]" + | ||
800 | ": Requst application data exception {0}", e.Message); | ||
801 | result = e.Message; | ||
802 | return false; | ||
803 | } | ||
804 | return true; | ||
805 | } | ||
806 | public bool SetUserAppData(UserAppData props, ref string result) | ||
807 | { | ||
808 | string query = string.Empty; | ||
809 | |||
810 | query += "UPDATE userdata SET "; | ||
811 | query += "TagId = :TagId, "; | ||
812 | query += "DataKey = :DataKey, "; | ||
813 | query += "DataVal = :DataVal WHERE "; | ||
814 | query += "UserId = :UserId AND "; | ||
815 | query += "TagId = :TagId"; | ||
816 | |||
817 | try | ||
818 | { | ||
819 | using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) | ||
820 | { | ||
821 | cmd.CommandText = query; | ||
822 | cmd.Parameters.AddWithValue(":UserId", props.UserId.ToString()); | ||
823 | cmd.Parameters.AddWithValue(":TagId", props.TagId.ToString ()); | ||
824 | cmd.Parameters.AddWithValue(":DataKey", props.DataKey.ToString ()); | ||
825 | cmd.Parameters.AddWithValue(":DataVal", props.DataKey.ToString ()); | ||
826 | |||
827 | cmd.ExecuteNonQuery(); | ||
828 | } | ||
829 | } | ||
830 | catch (Exception e) | ||
831 | { | ||
832 | m_log.DebugFormat("[PROFILES_DATA]" + | ||
833 | ": SetUserData exception {0}", e.Message); | ||
834 | return false; | ||
835 | } | ||
836 | return true; | ||
837 | } | ||
838 | public OSDArray GetUserImageAssets(UUID avatarId) | ||
839 | { | ||
840 | IDataReader reader = null; | ||
841 | OSDArray data = new OSDArray(); | ||
842 | string query = "SELECT `snapshotuuid` FROM {0} WHERE `creatoruuid` = :Id"; | ||
843 | |||
844 | // Get classified image assets | ||
845 | |||
846 | |||
847 | try | ||
848 | { | ||
849 | using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) | ||
850 | { | ||
851 | cmd.CommandText = query; | ||
852 | cmd.Parameters.AddWithValue(":Id", avatarId.ToString()); | ||
853 | |||
854 | using (reader = cmd.ExecuteReader(CommandBehavior.SingleRow)) | ||
855 | { | ||
856 | while(reader.Read()) | ||
857 | { | ||
858 | data.Add(new OSDString((string)reader["snapshotuuid"].ToString())); | ||
859 | } | ||
860 | } | ||
861 | } | ||
862 | |||
863 | using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) | ||
864 | { | ||
865 | cmd.CommandText = query; | ||
866 | cmd.Parameters.AddWithValue(":Id", avatarId.ToString()); | ||
867 | |||
868 | using (reader = cmd.ExecuteReader(CommandBehavior.SingleRow)) | ||
869 | { | ||
870 | if(reader.Read()) | ||
871 | { | ||
872 | data.Add(new OSDString((string)reader["snapshotuuid"].ToString ())); | ||
873 | } | ||
874 | } | ||
875 | } | ||
876 | |||
877 | query = "SELECT `profileImage`, `profileFirstImage` FROM `userprofile` WHERE `useruuid` = :Id"; | ||
878 | |||
879 | using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) | ||
880 | { | ||
881 | cmd.CommandText = query; | ||
882 | cmd.Parameters.AddWithValue(":Id", avatarId.ToString()); | ||
883 | |||
884 | using (reader = cmd.ExecuteReader(CommandBehavior.SingleRow)) | ||
885 | { | ||
886 | if(reader.Read()) | ||
887 | { | ||
888 | data.Add(new OSDString((string)reader["profileImage"].ToString ())); | ||
889 | data.Add(new OSDString((string)reader["profileFirstImage"].ToString ())); | ||
890 | } | ||
891 | } | ||
892 | } | ||
893 | } | ||
894 | catch (Exception e) | ||
895 | { | ||
896 | m_log.DebugFormat("[PROFILES_DATA]" + | ||
897 | ": GetAvatarNotes exception {0}", e.Message); | ||
898 | } | ||
899 | return data; | ||
900 | } | ||
901 | #endregion | ||
902 | } | ||
903 | } | ||
904 | |||