aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Data
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/Data.DB4o/DB4oGridData.cs17
-rw-r--r--OpenSim/Framework/Data.DB4o/DB4oManager.cs21
-rw-r--r--OpenSim/Framework/Data.DB4o/DB4oUserData.cs24
-rw-r--r--OpenSim/Framework/Data.DB4o/Properties/AssemblyInfo.cs31
-rw-r--r--OpenSim/Framework/Data.MSSQL/MSSQLGridData.cs4
-rw-r--r--OpenSim/Framework/Data.MSSQL/MSSQLManager.cs68
-rw-r--r--OpenSim/Framework/Data.MSSQL/Properties/AssemblyInfo.cs31
-rw-r--r--OpenSim/Framework/Data.MySQL/MySQLAssetData.cs43
-rw-r--r--OpenSim/Framework/Data.MySQL/MySQLGridData.cs21
-rw-r--r--OpenSim/Framework/Data.MySQL/MySQLInventoryData.cs117
-rw-r--r--OpenSim/Framework/Data.MySQL/MySQLLogData.cs13
-rw-r--r--OpenSim/Framework/Data.MySQL/MySQLManager.cs329
-rw-r--r--OpenSim/Framework/Data.MySQL/MySQLUserData.cs52
-rw-r--r--OpenSim/Framework/Data.MySQL/Properties/AssemblyInfo.cs31
-rw-r--r--OpenSim/Framework/Data.SQLite/Properties/AssemblyInfo.cs31
-rw-r--r--OpenSim/Framework/Data.SQLite/SQLiteAssetData.cs125
-rw-r--r--OpenSim/Framework/Data.SQLite/SQLiteBase.cs102
-rw-r--r--OpenSim/Framework/Data.SQLite/SQLiteGridData.cs2
-rw-r--r--OpenSim/Framework/Data.SQLite/SQLiteInventoryStore.cs189
-rw-r--r--OpenSim/Framework/Data.SQLite/SQLiteManager.cs132
-rw-r--r--OpenSim/Framework/Data.SQLite/SQLiteUserData.cs261
-rw-r--r--OpenSim/Framework/Data/GridData.cs3
-rw-r--r--OpenSim/Framework/Data/ILogData.cs7
-rw-r--r--OpenSim/Framework/Data/IniConfig.cs22
-rw-r--r--OpenSim/Framework/Data/Properties/AssemblyInfo.cs31
-rw-r--r--OpenSim/Framework/Data/RegionProfileData.cs63
-rw-r--r--OpenSim/Framework/Data/ReservationData.cs4
27 files changed, 969 insertions, 805 deletions
diff --git a/OpenSim/Framework/Data.DB4o/DB4oGridData.cs b/OpenSim/Framework/Data.DB4o/DB4oGridData.cs
index bc7225a..a96d9bd 100644
--- a/OpenSim/Framework/Data.DB4o/DB4oGridData.cs
+++ b/OpenSim/Framework/Data.DB4o/DB4oGridData.cs
@@ -34,18 +34,19 @@ namespace OpenSim.Framework.Data.DB4o
34 /// <summary> 34 /// <summary>
35 /// A grid server storage mechanism employing the DB4o database system 35 /// A grid server storage mechanism employing the DB4o database system
36 /// </summary> 36 /// </summary>
37 class DB4oGridData : IGridData 37 internal class DB4oGridData : IGridData
38 { 38 {
39 /// <summary> 39 /// <summary>
40 /// The database manager object 40 /// The database manager object
41 /// </summary> 41 /// </summary>
42 DB4oGridManager manager; 42 private DB4oGridManager manager;
43 43
44 /// <summary> 44 /// <summary>
45 /// Called when the plugin is first loaded (as constructors are not called) 45 /// Called when the plugin is first loaded (as constructors are not called)
46 /// </summary> 46 /// </summary>
47 public void Initialise() { 47 public void Initialise()
48 manager = new DB4oGridManager("gridserver.yap"); 48 {
49 manager = new DB4oGridManager("gridserver.yap");
49 } 50 }
50 51
51 /// <summary> 52 /// <summary>
@@ -93,7 +94,8 @@ namespace OpenSim.Framework.Data.DB4o
93 if (manager.simProfiles.ContainsKey(uuid)) 94 if (manager.simProfiles.ContainsKey(uuid))
94 return manager.simProfiles[uuid]; 95 return manager.simProfiles[uuid];
95 } 96 }
96 throw new Exception("Unable to find profile with UUID (" + uuid.ToStringHyphenated() + "). Total Registered Regions: " + manager.simProfiles.Count); 97 throw new Exception("Unable to find profile with UUID (" + uuid.ToStringHyphenated() +
98 "). Total Registered Regions: " + manager.simProfiles.Count);
97 } 99 }
98 100
99 /// <summary> 101 /// <summary>
@@ -123,7 +125,8 @@ namespace OpenSim.Framework.Data.DB4o
123 /// <param name="handle">The location the region is logging into (unused in Db4o)</param> 125 /// <param name="handle">The location the region is logging into (unused in Db4o)</param>
124 /// <param name="key">The shared secret</param> 126 /// <param name="key">The shared secret</param>
125 /// <returns>Authenticated?</returns> 127 /// <returns>Authenticated?</returns>
126 public bool AuthenticateSim(LLUUID uuid, ulong handle, string key) { 128 public bool AuthenticateSim(LLUUID uuid, ulong handle, string key)
129 {
127 if (manager.simProfiles[uuid].regionRecvKey == key) 130 if (manager.simProfiles[uuid].regionRecvKey == key)
128 return true; 131 return true;
129 return false; 132 return false;
@@ -160,4 +163,4 @@ namespace OpenSim.Framework.Data.DB4o
160 return null; 163 return null;
161 } 164 }
162 } 165 }
163} 166} \ No newline at end of file
diff --git a/OpenSim/Framework/Data.DB4o/DB4oManager.cs b/OpenSim/Framework/Data.DB4o/DB4oManager.cs
index 9e8a03f..033413a 100644
--- a/OpenSim/Framework/Data.DB4o/DB4oManager.cs
+++ b/OpenSim/Framework/Data.DB4o/DB4oManager.cs
@@ -29,23 +29,23 @@ using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using Db4objects.Db4o; 30using Db4objects.Db4o;
31using libsecondlife; 31using libsecondlife;
32using OpenSim.Framework;
33 32
34namespace OpenSim.Framework.Data.DB4o 33namespace OpenSim.Framework.Data.DB4o
35{ 34{
36 /// <summary> 35 /// <summary>
37 /// A Database manager for Db4o 36 /// A Database manager for Db4o
38 /// </summary> 37 /// </summary>
39 class DB4oGridManager 38 internal class DB4oGridManager
40 { 39 {
41 /// <summary> 40 /// <summary>
42 /// A list of the current regions connected (in-memory cache) 41 /// A list of the current regions connected (in-memory cache)
43 /// </summary> 42 /// </summary>
44 public Dictionary<LLUUID, RegionProfileData> simProfiles = new Dictionary<LLUUID, RegionProfileData>(); 43 public Dictionary<LLUUID, RegionProfileData> simProfiles = new Dictionary<LLUUID, RegionProfileData>();
44
45 /// <summary> 45 /// <summary>
46 /// Database File Name 46 /// Database File Name
47 /// </summary> 47 /// </summary>
48 string dbfl; 48 private string dbfl;
49 49
50 /// <summary> 50 /// <summary>
51 /// Creates a new grid storage manager 51 /// Creates a new grid storage manager
@@ -56,7 +56,7 @@ namespace OpenSim.Framework.Data.DB4o
56 dbfl = db4odb; 56 dbfl = db4odb;
57 IObjectContainer database; 57 IObjectContainer database;
58 database = Db4oFactory.OpenFile(dbfl); 58 database = Db4oFactory.OpenFile(dbfl);
59 IObjectSet result = database.Get(typeof(RegionProfileData)); 59 IObjectSet result = database.Get(typeof (RegionProfileData));
60 // Loads the file into the in-memory cache 60 // Loads the file into the in-memory cache
61 foreach (RegionProfileData row in result) 61 foreach (RegionProfileData row in result)
62 { 62 {
@@ -94,23 +94,22 @@ namespace OpenSim.Framework.Data.DB4o
94 return false; 94 return false;
95 } 95 }
96 } 96 }
97
98
99 } 97 }
100 98
101 /// <summary> 99 /// <summary>
102 /// A manager for the DB4o database (user profiles) 100 /// A manager for the DB4o database (user profiles)
103 /// </summary> 101 /// </summary>
104 class DB4oUserManager 102 internal class DB4oUserManager
105 { 103 {
106 /// <summary> 104 /// <summary>
107 /// A list of the user profiles (in memory cache) 105 /// A list of the user profiles (in memory cache)
108 /// </summary> 106 /// </summary>
109 public Dictionary<LLUUID, UserProfileData> userProfiles = new Dictionary<LLUUID, UserProfileData>(); 107 public Dictionary<LLUUID, UserProfileData> userProfiles = new Dictionary<LLUUID, UserProfileData>();
108
110 /// <summary> 109 /// <summary>
111 /// Database filename 110 /// Database filename
112 /// </summary> 111 /// </summary>
113 string dbfl; 112 private string dbfl;
114 113
115 /// <summary> 114 /// <summary>
116 /// Initialises a new DB manager 115 /// Initialises a new DB manager
@@ -122,7 +121,7 @@ namespace OpenSim.Framework.Data.DB4o
122 IObjectContainer database; 121 IObjectContainer database;
123 database = Db4oFactory.OpenFile(dbfl); 122 database = Db4oFactory.OpenFile(dbfl);
124 // Load to cache 123 // Load to cache
125 IObjectSet result = database.Get(typeof(UserProfileData)); 124 IObjectSet result = database.Get(typeof (UserProfileData));
126 foreach (UserProfileData row in result) 125 foreach (UserProfileData row in result)
127 { 126 {
128 if (userProfiles.ContainsKey(row.UUID)) 127 if (userProfiles.ContainsKey(row.UUID))
@@ -144,7 +143,7 @@ namespace OpenSim.Framework.Data.DB4o
144 /// <param name="record">The profile to update</param> 143 /// <param name="record">The profile to update</param>
145 /// <returns>true on success, false on fail to persist to db</returns> 144 /// <returns>true on success, false on fail to persist to db</returns>
146 public bool UpdateRecord(UserProfileData record) 145 public bool UpdateRecord(UserProfileData record)
147 { 146 {
148 if (userProfiles.ContainsKey(record.UUID)) 147 if (userProfiles.ContainsKey(record.UUID))
149 { 148 {
150 userProfiles[record.UUID] = record; 149 userProfiles[record.UUID] = record;
@@ -168,4 +167,4 @@ namespace OpenSim.Framework.Data.DB4o
168 } 167 }
169 } 168 }
170 } 169 }
171} 170} \ No newline at end of file
diff --git a/OpenSim/Framework/Data.DB4o/DB4oUserData.cs b/OpenSim/Framework/Data.DB4o/DB4oUserData.cs
index b00fd02..c7113bf 100644
--- a/OpenSim/Framework/Data.DB4o/DB4oUserData.cs
+++ b/OpenSim/Framework/Data.DB4o/DB4oUserData.cs
@@ -28,8 +28,6 @@
28using System; 28using System;
29using System.IO; 29using System.IO;
30using libsecondlife; 30using libsecondlife;
31using OpenSim.Framework;
32using OpenSim.Framework;
33 31
34namespace OpenSim.Framework.Data.DB4o 32namespace OpenSim.Framework.Data.DB4o
35{ 33{
@@ -41,14 +39,14 @@ namespace OpenSim.Framework.Data.DB4o
41 /// <summary> 39 /// <summary>
42 /// The database manager 40 /// The database manager
43 /// </summary> 41 /// </summary>
44 DB4oUserManager manager; 42 private DB4oUserManager manager;
45 43
46 /// <summary> 44 /// <summary>
47 /// Artificial constructor called upon plugin load 45 /// Artificial constructor called upon plugin load
48 /// </summary> 46 /// </summary>
49 public void Initialise() 47 public void Initialise()
50 { 48 {
51 manager = new DB4oUserManager(Path.Combine(Util.dataDir(),"userprofiles.yap")); 49 manager = new DB4oUserManager(Path.Combine(Util.dataDir(), "userprofiles.yap"));
52 } 50 }
53 51
54 /// <summary> 52 /// <summary>
@@ -58,7 +56,7 @@ namespace OpenSim.Framework.Data.DB4o
58 /// <returns>A user profile</returns> 56 /// <returns>A user profile</returns>
59 public UserProfileData GetUserByUUID(LLUUID uuid) 57 public UserProfileData GetUserByUUID(LLUUID uuid)
60 { 58 {
61 if(manager.userProfiles.ContainsKey(uuid)) 59 if (manager.userProfiles.ContainsKey(uuid))
62 return manager.userProfiles[uuid]; 60 return manager.userProfiles[uuid];
63 return null; 61 return null;
64 } 62 }
@@ -95,7 +93,7 @@ namespace OpenSim.Framework.Data.DB4o
95 /// <param name="uuid">The users account ID</param> 93 /// <param name="uuid">The users account ID</param>
96 /// <returns>A matching users profile</returns> 94 /// <returns>A matching users profile</returns>
97 public UserAgentData GetAgentByUUID(LLUUID uuid) 95 public UserAgentData GetAgentByUUID(LLUUID uuid)
98 { 96 {
99 try 97 try
100 { 98 {
101 return GetUserByUUID(uuid).currentAgent; 99 return GetUserByUUID(uuid).currentAgent;
@@ -126,7 +124,7 @@ namespace OpenSim.Framework.Data.DB4o
126 { 124 {
127 try 125 try
128 { 126 {
129 return GetUserByName(fname,lname).currentAgent; 127 return GetUserByName(fname, lname).currentAgent;
130 } 128 }
131 catch (Exception) 129 catch (Exception)
132 { 130 {
@@ -149,7 +147,7 @@ namespace OpenSim.Framework.Data.DB4o
149 Console.WriteLine(e.ToString()); 147 Console.WriteLine(e.ToString());
150 } 148 }
151 } 149 }
152 150
153 /// <summary> 151 /// <summary>
154 /// Creates a new user profile 152 /// Creates a new user profile
155 /// </summary> 153 /// </summary>
@@ -157,15 +155,17 @@ namespace OpenSim.Framework.Data.DB4o
157 /// <returns>True on success, false on error</returns> 155 /// <returns>True on success, false on error</returns>
158 public bool UpdateUserProfile(UserProfileData user) 156 public bool UpdateUserProfile(UserProfileData user)
159 { 157 {
160 try { 158 try
159 {
161 return manager.UpdateRecord(user); 160 return manager.UpdateRecord(user);
162 } catch (Exception e) { 161 }
162 catch (Exception e)
163 {
163 Console.WriteLine(e.ToString()); 164 Console.WriteLine(e.ToString());
164 return false; 165 return false;
165 } 166 }
166 } 167 }
167 168
168
169 169
170 /// <summary> 170 /// <summary>
171 /// Creates a new user agent 171 /// Creates a new user agent
@@ -219,4 +219,4 @@ namespace OpenSim.Framework.Data.DB4o
219 return "0.1"; 219 return "0.1";
220 } 220 }
221 } 221 }
222} 222} \ No newline at end of file
diff --git a/OpenSim/Framework/Data.DB4o/Properties/AssemblyInfo.cs b/OpenSim/Framework/Data.DB4o/Properties/AssemblyInfo.cs
index 52d09fa..6183b6e 100644
--- a/OpenSim/Framework/Data.DB4o/Properties/AssemblyInfo.cs
+++ b/OpenSim/Framework/Data.DB4o/Properties/AssemblyInfo.cs
@@ -1,24 +1,28 @@
1using System.Reflection; 1using System.Reflection;
2using System.Runtime.InteropServices; 2using System.Runtime.InteropServices;
3
3// General Information about an assembly is controlled through the following 4// General Information about an assembly is controlled through the following
4// set of attributes. Change these attribute values to modify the information 5// set of attributes. Change these attribute values to modify the information
5// associated with an assembly. 6// associated with an assembly.
6[assembly: AssemblyTitle("OpenSim.Framework.Data.DB4o")] 7
7[assembly: AssemblyDescription("")] 8[assembly : AssemblyTitle("OpenSim.Framework.Data.DB4o")]
8[assembly: AssemblyConfiguration("")] 9[assembly : AssemblyDescription("")]
9[assembly: AssemblyCompany("")] 10[assembly : AssemblyConfiguration("")]
10[assembly: AssemblyProduct("OpenSim.Framework.Data.DB4o")] 11[assembly : AssemblyCompany("")]
11[assembly: AssemblyCopyright("Copyright © 2007")] 12[assembly : AssemblyProduct("OpenSim.Framework.Data.DB4o")]
12[assembly: AssemblyTrademark("")] 13[assembly : AssemblyCopyright("Copyright © 2007")]
13[assembly: AssemblyCulture("")] 14[assembly : AssemblyTrademark("")]
15[assembly : AssemblyCulture("")]
14 16
15// Setting ComVisible to false makes the types in this assembly not visible 17// Setting ComVisible to false makes the types in this assembly not visible
16// to COM components. If you need to access a type in this assembly from 18// to COM components. If you need to access a type in this assembly from
17// COM, set the ComVisible attribute to true on that type. 19// COM, set the ComVisible attribute to true on that type.
18[assembly: ComVisible(false)] 20
21[assembly : ComVisible(false)]
19 22
20// The following GUID is for the ID of the typelib if this project is exposed to COM 23// The following GUID is for the ID of the typelib if this project is exposed to COM
21[assembly: Guid("57991e15-79da-41b7-aa06-2e6b49165a63")] 24
25[assembly : Guid("57991e15-79da-41b7-aa06-2e6b49165a63")]
22 26
23// Version information for an assembly consists of the following four values: 27// Version information for an assembly consists of the following four values:
24// 28//
@@ -29,5 +33,6 @@ using System.Runtime.InteropServices;
29// 33//
30// You can specify all the values or you can default the Revision and Build Numbers 34// You can specify all the values or you can default the Revision and Build Numbers
31// by using the '*' as shown below: 35// by using the '*' as shown below:
32[assembly: AssemblyVersion("1.0.0.0")] 36
33[assembly: AssemblyFileVersion("1.0.0.0")] 37[assembly : AssemblyVersion("1.0.0.0")]
38[assembly : AssemblyFileVersion("1.0.0.0")] \ No newline at end of file
diff --git a/OpenSim/Framework/Data.MSSQL/MSSQLGridData.cs b/OpenSim/Framework/Data.MSSQL/MSSQLGridData.cs
index e628882..1946790 100644
--- a/OpenSim/Framework/Data.MSSQL/MSSQLGridData.cs
+++ b/OpenSim/Framework/Data.MSSQL/MSSQLGridData.cs
@@ -185,10 +185,10 @@ namespace OpenSim.Framework.Data.MSSQL
185 byte[] hash = HashProvider.ComputeHash(stream); 185 byte[] hash = HashProvider.ComputeHash(stream);
186 return false; 186 return false;
187 } 187 }
188
188 public ReservationData GetReservationAtPoint(uint x, uint y) 189 public ReservationData GetReservationAtPoint(uint x, uint y)
189 { 190 {
190 return null; 191 return null;
191 } 192 }
192 } 193 }
193 194} \ No newline at end of file
194}
diff --git a/OpenSim/Framework/Data.MSSQL/MSSQLManager.cs b/OpenSim/Framework/Data.MSSQL/MSSQLManager.cs
index 77d29f7..c0b2edf 100644
--- a/OpenSim/Framework/Data.MSSQL/MSSQLManager.cs
+++ b/OpenSim/Framework/Data.MSSQL/MSSQLManager.cs
@@ -36,12 +36,12 @@ namespace OpenSim.Framework.Data.MSSQL
36 /// <summary> 36 /// <summary>
37 /// A management class for the MS SQL Storage Engine 37 /// A management class for the MS SQL Storage Engine
38 /// </summary> 38 /// </summary>
39 class MSSqlManager 39 internal class MSSqlManager
40 { 40 {
41 /// <summary> 41 /// <summary>
42 /// The database connection object 42 /// The database connection object
43 /// </summary> 43 /// </summary>
44 IDbConnection dbcon; 44 private IDbConnection dbcon;
45 45
46 /// <summary> 46 /// <summary>
47 /// Initialises and creates a new Sql connection and maintains it. 47 /// Initialises and creates a new Sql connection and maintains it.
@@ -55,7 +55,8 @@ namespace OpenSim.Framework.Data.MSSQL
55 { 55 {
56 try 56 try
57 { 57 {
58 string connectionString = "Server=" + hostname + ";Database=" + database + ";User ID=" + username + ";Password=" + password + ";Pooling=" + cpooling + ";"; 58 string connectionString = "Server=" + hostname + ";Database=" + database + ";User ID=" + username +
59 ";Password=" + password + ";Pooling=" + cpooling + ";";
59 dbcon = new SqlConnection(connectionString); 60 dbcon = new SqlConnection(connectionString);
60 61
61 dbcon.Open(); 62 dbcon.Open();
@@ -83,14 +84,14 @@ namespace OpenSim.Framework.Data.MSSQL
83 /// <returns>A Sql DB Command</returns> 84 /// <returns>A Sql DB Command</returns>
84 public IDbCommand Query(string sql, Dictionary<string, string> parameters) 85 public IDbCommand Query(string sql, Dictionary<string, string> parameters)
85 { 86 {
86 SqlCommand dbcommand = (SqlCommand)dbcon.CreateCommand(); 87 SqlCommand dbcommand = (SqlCommand) dbcon.CreateCommand();
87 dbcommand.CommandText = sql; 88 dbcommand.CommandText = sql;
88 foreach (KeyValuePair<string, string> param in parameters) 89 foreach (KeyValuePair<string, string> param in parameters)
89 { 90 {
90 dbcommand.Parameters.AddWithValue(param.Key, param.Value); 91 dbcommand.Parameters.AddWithValue(param.Key, param.Value);
91 } 92 }
92 93
93 return (IDbCommand)dbcommand; 94 return (IDbCommand) dbcommand;
94 } 95 }
95 96
96 /// <summary> 97 /// <summary>
@@ -105,42 +106,42 @@ namespace OpenSim.Framework.Data.MSSQL
105 if (reader.Read()) 106 if (reader.Read())
106 { 107 {
107 // Region Main 108 // Region Main
108 regionprofile.regionHandle = (ulong)reader["regionHandle"]; 109 regionprofile.regionHandle = (ulong) reader["regionHandle"];
109 regionprofile.regionName = (string)reader["regionName"]; 110 regionprofile.regionName = (string) reader["regionName"];
110 regionprofile.UUID = new LLUUID((string)reader["uuid"]); 111 regionprofile.UUID = new LLUUID((string) reader["uuid"]);
111 112
112 // Secrets 113 // Secrets
113 regionprofile.regionRecvKey = (string)reader["regionRecvKey"]; 114 regionprofile.regionRecvKey = (string) reader["regionRecvKey"];
114 regionprofile.regionSecret = (string)reader["regionSecret"]; 115 regionprofile.regionSecret = (string) reader["regionSecret"];
115 regionprofile.regionSendKey = (string)reader["regionSendKey"]; 116 regionprofile.regionSendKey = (string) reader["regionSendKey"];
116 117
117 // Region Server 118 // Region Server
118 regionprofile.regionDataURI = (string)reader["regionDataURI"]; 119 regionprofile.regionDataURI = (string) reader["regionDataURI"];
119 regionprofile.regionOnline = false; // Needs to be pinged before this can be set. 120 regionprofile.regionOnline = false; // Needs to be pinged before this can be set.
120 regionprofile.serverIP = (string)reader["serverIP"]; 121 regionprofile.serverIP = (string) reader["serverIP"];
121 regionprofile.serverPort = (uint)reader["serverPort"]; 122 regionprofile.serverPort = (uint) reader["serverPort"];
122 regionprofile.serverURI = (string)reader["serverURI"]; 123 regionprofile.serverURI = (string) reader["serverURI"];
123 124
124 // Location 125 // Location
125 regionprofile.regionLocX = (uint)((int)reader["locX"]); 126 regionprofile.regionLocX = (uint) ((int) reader["locX"]);
126 regionprofile.regionLocY = (uint)((int)reader["locY"]); 127 regionprofile.regionLocY = (uint) ((int) reader["locY"]);
127 regionprofile.regionLocZ = (uint)((int)reader["locZ"]); 128 regionprofile.regionLocZ = (uint) ((int) reader["locZ"]);
128 129
129 // Neighbours - 0 = No Override 130 // Neighbours - 0 = No Override
130 regionprofile.regionEastOverrideHandle = (ulong)reader["eastOverrideHandle"]; 131 regionprofile.regionEastOverrideHandle = (ulong) reader["eastOverrideHandle"];
131 regionprofile.regionWestOverrideHandle = (ulong)reader["westOverrideHandle"]; 132 regionprofile.regionWestOverrideHandle = (ulong) reader["westOverrideHandle"];
132 regionprofile.regionSouthOverrideHandle = (ulong)reader["southOverrideHandle"]; 133 regionprofile.regionSouthOverrideHandle = (ulong) reader["southOverrideHandle"];
133 regionprofile.regionNorthOverrideHandle = (ulong)reader["northOverrideHandle"]; 134 regionprofile.regionNorthOverrideHandle = (ulong) reader["northOverrideHandle"];
134 135
135 // Assets 136 // Assets
136 regionprofile.regionAssetURI = (string)reader["regionAssetURI"]; 137 regionprofile.regionAssetURI = (string) reader["regionAssetURI"];
137 regionprofile.regionAssetRecvKey = (string)reader["regionAssetRecvKey"]; 138 regionprofile.regionAssetRecvKey = (string) reader["regionAssetRecvKey"];
138 regionprofile.regionAssetSendKey = (string)reader["regionAssetSendKey"]; 139 regionprofile.regionAssetSendKey = (string) reader["regionAssetSendKey"];
139 140
140 // Userserver 141 // Userserver
141 regionprofile.regionUserURI = (string)reader["regionUserURI"]; 142 regionprofile.regionUserURI = (string) reader["regionUserURI"];
142 regionprofile.regionUserRecvKey = (string)reader["regionUserRecvKey"]; 143 regionprofile.regionUserRecvKey = (string) reader["regionUserRecvKey"];
143 regionprofile.regionUserSendKey = (string)reader["regionUserSendKey"]; 144 regionprofile.regionUserSendKey = (string) reader["regionUserSendKey"];
144 } 145 }
145 else 146 else
146 { 147 {
@@ -156,12 +157,15 @@ namespace OpenSim.Framework.Data.MSSQL
156 /// <returns>Successful?</returns> 157 /// <returns>Successful?</returns>
157 public bool insertRow(RegionProfileData profile) 158 public bool insertRow(RegionProfileData profile)
158 { 159 {
159 string sql = "REPLACE INTO regions VALUES (regionHandle, regionName, uuid, regionRecvKey, regionSecret, regionSendKey, regionDataURI, "; 160 string sql =
160 sql += "serverIP, serverPort, serverURI, locX, locY, locZ, eastOverrideHandle, westOverrideHandle, southOverrideHandle, northOverrideHandle, regionAssetURI, regionAssetRecvKey, "; 161 "REPLACE INTO regions VALUES (regionHandle, regionName, uuid, regionRecvKey, regionSecret, regionSendKey, regionDataURI, ";
162 sql +=
163 "serverIP, serverPort, serverURI, locX, locY, locZ, eastOverrideHandle, westOverrideHandle, southOverrideHandle, northOverrideHandle, regionAssetURI, regionAssetRecvKey, ";
161 sql += "regionAssetSendKey, regionUserURI, regionUserRecvKey, regionUserSendKey) VALUES "; 164 sql += "regionAssetSendKey, regionUserURI, regionUserRecvKey, regionUserSendKey) VALUES ";
162 165
163 sql += "(@regionHandle, @regionName, @uuid, @regionRecvKey, @regionSecret, @regionSendKey, @regionDataURI, "; 166 sql += "(@regionHandle, @regionName, @uuid, @regionRecvKey, @regionSecret, @regionSendKey, @regionDataURI, ";
164 sql += "@serverIP, @serverPort, @serverURI, @locX, @locY, @locZ, @eastOverrideHandle, @westOverrideHandle, @southOverrideHandle, @northOverrideHandle, @regionAssetURI, @regionAssetRecvKey, "; 167 sql +=
168 "@serverIP, @serverPort, @serverURI, @locX, @locY, @locZ, @eastOverrideHandle, @westOverrideHandle, @southOverrideHandle, @northOverrideHandle, @regionAssetURI, @regionAssetRecvKey, ";
165 sql += "@regionAssetSendKey, @regionUserURI, @regionUserRecvKey, @regionUserSendKey);"; 169 sql += "@regionAssetSendKey, @regionUserURI, @regionUserRecvKey, @regionUserSendKey);";
166 170
167 Dictionary<string, string> parameters = new Dictionary<string, string>(); 171 Dictionary<string, string> parameters = new Dictionary<string, string>();
@@ -208,4 +212,4 @@ namespace OpenSim.Framework.Data.MSSQL
208 return returnval; 212 return returnval;
209 } 213 }
210 } 214 }
211} 215} \ No newline at end of file
diff --git a/OpenSim/Framework/Data.MSSQL/Properties/AssemblyInfo.cs b/OpenSim/Framework/Data.MSSQL/Properties/AssemblyInfo.cs
index eeac06c..6846ecf 100644
--- a/OpenSim/Framework/Data.MSSQL/Properties/AssemblyInfo.cs
+++ b/OpenSim/Framework/Data.MSSQL/Properties/AssemblyInfo.cs
@@ -1,24 +1,28 @@
1using System.Reflection; 1using System.Reflection;
2using System.Runtime.InteropServices; 2using System.Runtime.InteropServices;
3
3// General Information about an assembly is controlled through the following 4// General Information about an assembly is controlled through the following
4// set of attributes. Change these attribute values to modify the information 5// set of attributes. Change these attribute values to modify the information
5// associated with an assembly. 6// associated with an assembly.
6[assembly: AssemblyTitle("OpenSim.Framework.Data.MSSQL")] 7
7[assembly: AssemblyDescription("")] 8[assembly : AssemblyTitle("OpenSim.Framework.Data.MSSQL")]
8[assembly: AssemblyConfiguration("")] 9[assembly : AssemblyDescription("")]
9[assembly: AssemblyCompany("")] 10[assembly : AssemblyConfiguration("")]
10[assembly: AssemblyProduct("OpenSim.Framework.Data.MSSQL")] 11[assembly : AssemblyCompany("")]
11[assembly: AssemblyCopyright("Copyright © 2007")] 12[assembly : AssemblyProduct("OpenSim.Framework.Data.MSSQL")]
12[assembly: AssemblyTrademark("")] 13[assembly : AssemblyCopyright("Copyright © 2007")]
13[assembly: AssemblyCulture("")] 14[assembly : AssemblyTrademark("")]
15[assembly : AssemblyCulture("")]
14 16
15// Setting ComVisible to false makes the types in this assembly not visible 17// Setting ComVisible to false makes the types in this assembly not visible
16// to COM components. If you need to access a type in this assembly from 18// to COM components. If you need to access a type in this assembly from
17// COM, set the ComVisible attribute to true on that type. 19// COM, set the ComVisible attribute to true on that type.
18[assembly: ComVisible(false)] 20
21[assembly : ComVisible(false)]
19 22
20// The following GUID is for the ID of the typelib if this project is exposed to COM 23// The following GUID is for the ID of the typelib if this project is exposed to COM
21[assembly: Guid("0e1c1ca4-2cf2-4315-b0e7-432c02feea8a")] 24
25[assembly : Guid("0e1c1ca4-2cf2-4315-b0e7-432c02feea8a")]
22 26
23// Version information for an assembly consists of the following four values: 27// Version information for an assembly consists of the following four values:
24// 28//
@@ -29,5 +33,6 @@ using System.Runtime.InteropServices;
29// 33//
30// You can specify all the values or you can default the Revision and Build Numbers 34// You can specify all the values or you can default the Revision and Build Numbers
31// by using the '*' as shown below: 35// by using the '*' as shown below:
32[assembly: AssemblyVersion("1.0.0.0")] 36
33[assembly: AssemblyFileVersion("1.0.0.0")] 37[assembly : AssemblyVersion("1.0.0.0")]
38[assembly : AssemblyFileVersion("1.0.0.0")] \ No newline at end of file
diff --git a/OpenSim/Framework/Data.MySQL/MySQLAssetData.cs b/OpenSim/Framework/Data.MySQL/MySQLAssetData.cs
index bf895c0..055cd92 100644
--- a/OpenSim/Framework/Data.MySQL/MySQLAssetData.cs
+++ b/OpenSim/Framework/Data.MySQL/MySQLAssetData.cs
@@ -28,18 +28,17 @@
28 28
29using System; 29using System;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using MySql.Data.MySqlClient; 31using System.Data;
32
33using libsecondlife; 32using libsecondlife;
33using MySql.Data.MySqlClient;
34using OpenSim.Framework.Console; 34using OpenSim.Framework.Console;
35using OpenSim.Framework.Interfaces;
36using OpenSim.Framework;
37 35
38namespace OpenSim.Framework.Data.MySQL 36namespace OpenSim.Framework.Data.MySQL
39{ 37{
40 class MySQLAssetData : IAssetProvider 38 internal class MySQLAssetData : IAssetProvider
41 { 39 {
42 MySQLManager _dbConnection; 40 private MySQLManager _dbConnection;
41
43 #region IAssetProvider Members 42 #region IAssetProvider Members
44 43
45 private void UpgradeAssetsTable(string oldVersion) 44 private void UpgradeAssetsTable(string oldVersion)
@@ -58,14 +57,12 @@ namespace OpenSim.Framework.Data.MySQL
58 /// </summary> 57 /// </summary>
59 private void TestTables() 58 private void TestTables()
60 { 59 {
61
62 Dictionary<string, string> tableList = new Dictionary<string, string>(); 60 Dictionary<string, string> tableList = new Dictionary<string, string>();
63 61
64 tableList["assets"] = null; 62 tableList["assets"] = null;
65 _dbConnection.GetTableVersion(tableList); 63 _dbConnection.GetTableVersion(tableList);
66 64
67 UpgradeAssetsTable(tableList["assets"]); 65 UpgradeAssetsTable(tableList["assets"]);
68
69 } 66 }
70 67
71 public AssetBase FetchAsset(LLUUID assetID) 68 public AssetBase FetchAsset(LLUUID assetID)
@@ -73,21 +70,24 @@ namespace OpenSim.Framework.Data.MySQL
73 AssetBase asset = null; 70 AssetBase asset = null;
74 lock (_dbConnection) 71 lock (_dbConnection)
75 { 72 {
76 MySqlCommand cmd = new MySqlCommand("SELECT name, description, assetType, invType, local, temporary, data FROM assets WHERE id=?id", _dbConnection.Connection); 73 MySqlCommand cmd =
74 new MySqlCommand(
75 "SELECT name, description, assetType, invType, local, temporary, data FROM assets WHERE id=?id",
76 _dbConnection.Connection);
77 MySqlParameter p = cmd.Parameters.Add("?id", MySqlDbType.Binary, 16); 77 MySqlParameter p = cmd.Parameters.Add("?id", MySqlDbType.Binary, 16);
78 p.Value = assetID.GetBytes(); 78 p.Value = assetID.GetBytes();
79 using (MySqlDataReader dbReader = cmd.ExecuteReader(System.Data.CommandBehavior.SingleRow)) 79 using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow))
80 { 80 {
81 if (dbReader.Read()) 81 if (dbReader.Read())
82 { 82 {
83 asset = new AssetBase(); 83 asset = new AssetBase();
84 asset.Data = (byte[])dbReader["data"]; 84 asset.Data = (byte[]) dbReader["data"];
85 asset.Description = (string)dbReader["description"]; 85 asset.Description = (string) dbReader["description"];
86 asset.FullID = assetID; 86 asset.FullID = assetID;
87 asset.InvType = (sbyte)dbReader["invType"]; 87 asset.InvType = (sbyte) dbReader["invType"];
88 asset.Local = ((sbyte)dbReader["local"]) != 0 ? true : false; 88 asset.Local = ((sbyte) dbReader["local"]) != 0 ? true : false;
89 asset.Name = (string)dbReader["name"]; 89 asset.Name = (string) dbReader["name"];
90 asset.Type = (sbyte)dbReader["assetType"]; 90 asset.Type = (sbyte) dbReader["assetType"];
91 } 91 }
92 } 92 }
93 } 93 }
@@ -96,8 +96,11 @@ namespace OpenSim.Framework.Data.MySQL
96 96
97 public void CreateAsset(AssetBase asset) 97 public void CreateAsset(AssetBase asset)
98 { 98 {
99 MySqlCommand cmd = new MySqlCommand("REPLACE INTO assets(id, name, description, assetType, invType, local, temporary, data)" + 99 MySqlCommand cmd =
100 "VALUES(?id, ?name, ?description, ?assetType, ?invType, ?local, ?temporary, ?data)", _dbConnection.Connection); 100 new MySqlCommand(
101 "REPLACE INTO assets(id, name, description, assetType, invType, local, temporary, data)" +
102 "VALUES(?id, ?name, ?description, ?assetType, ?invType, ?local, ?temporary, ?data)",
103 _dbConnection.Connection);
101 MySqlParameter p = cmd.Parameters.Add("?id", MySqlDbType.Binary, 16); 104 MySqlParameter p = cmd.Parameters.Add("?id", MySqlDbType.Binary, 16);
102 p.Value = asset.FullID.GetBytes(); 105 p.Value = asset.FullID.GetBytes();
103 cmd.Parameters.AddWithValue("?name", asset.Name); 106 cmd.Parameters.AddWithValue("?name", asset.Name);
@@ -148,7 +151,7 @@ namespace OpenSim.Framework.Data.MySQL
148 151
149 public string Version 152 public string Version
150 { 153 {
151 get { return _dbConnection.getVersion(); } 154 get { return _dbConnection.getVersion(); }
152 } 155 }
153 156
154 public string Name 157 public string Name
@@ -158,4 +161,4 @@ namespace OpenSim.Framework.Data.MySQL
158 161
159 #endregion 162 #endregion
160 } 163 }
161} 164} \ No newline at end of file
diff --git a/OpenSim/Framework/Data.MySQL/MySQLGridData.cs b/OpenSim/Framework/Data.MySQL/MySQLGridData.cs
index 9876ab1..fdfc61c 100644
--- a/OpenSim/Framework/Data.MySQL/MySQLGridData.cs
+++ b/OpenSim/Framework/Data.MySQL/MySQLGridData.cs
@@ -25,13 +25,13 @@
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28
28using System; 29using System;
29using System.Collections.Generic; 30using System.Collections.Generic;
30using System.Data; 31using System.Data;
31using System.Security.Cryptography; 32using System.Security.Cryptography;
32using System.Text; 33using System.Text;
33using libsecondlife; 34using libsecondlife;
34
35using OpenSim.Framework.Console; 35using OpenSim.Framework.Console;
36 36
37namespace OpenSim.Framework.Data.MySQL 37namespace OpenSim.Framework.Data.MySQL
@@ -59,7 +59,9 @@ namespace OpenSim.Framework.Data.MySQL
59 string settingPooling = GridDataMySqlFile.ParseFileReadValue("pooling"); 59 string settingPooling = GridDataMySqlFile.ParseFileReadValue("pooling");
60 string settingPort = GridDataMySqlFile.ParseFileReadValue("port"); 60 string settingPort = GridDataMySqlFile.ParseFileReadValue("port");
61 61
62 database = new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling, settingPort); 62 database =
63 new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling,
64 settingPort);
63 } 65 }
64 66
65 /// <summary> 67 /// <summary>
@@ -108,7 +110,10 @@ namespace OpenSim.Framework.Data.MySQL
108 param["?xmax"] = xmax.ToString(); 110 param["?xmax"] = xmax.ToString();
109 param["?ymax"] = ymax.ToString(); 111 param["?ymax"] = ymax.ToString();
110 112
111 IDbCommand result = database.Query("SELECT * FROM regions WHERE locX >= ?xmin AND locX <= ?xmax AND locY >= ?ymin AND locY <= ?ymax", param); 113 IDbCommand result =
114 database.Query(
115 "SELECT * FROM regions WHERE locX >= ?xmin AND locX <= ?xmax AND locY >= ?ymin AND locY <= ?ymax",
116 param);
112 IDataReader reader = result.ExecuteReader(); 117 IDataReader reader = result.ExecuteReader();
113 118
114 RegionProfileData row; 119 RegionProfileData row;
@@ -123,7 +128,6 @@ namespace OpenSim.Framework.Data.MySQL
123 result.Dispose(); 128 result.Dispose();
124 129
125 return rows.ToArray(); 130 return rows.ToArray();
126
127 } 131 }
128 } 132 }
129 catch (Exception e) 133 catch (Exception e)
@@ -266,7 +270,10 @@ namespace OpenSim.Framework.Data.MySQL
266 Dictionary<string, string> param = new Dictionary<string, string>(); 270 Dictionary<string, string> param = new Dictionary<string, string>();
267 param["?x"] = x.ToString(); 271 param["?x"] = x.ToString();
268 param["?y"] = y.ToString(); 272 param["?y"] = y.ToString();
269 IDbCommand result = database.Query("SELECT * FROM reservations WHERE resXMin <= ?x AND resXMax >= ?x AND resYMin <= ?y AND resYMax >= ?y", param); 273 IDbCommand result =
274 database.Query(
275 "SELECT * FROM reservations WHERE resXMin <= ?x AND resXMax >= ?x AND resYMin <= ?y AND resYMax >= ?y",
276 param);
270 IDataReader reader = result.ExecuteReader(); 277 IDataReader reader = result.ExecuteReader();
271 278
272 ReservationData row = database.readReservationRow(reader); 279 ReservationData row = database.readReservationRow(reader);
@@ -284,6 +291,4 @@ namespace OpenSim.Framework.Data.MySQL
284 } 291 }
285 } 292 }
286 } 293 }
287 294} \ No newline at end of file
288
289}
diff --git a/OpenSim/Framework/Data.MySQL/MySQLInventoryData.cs b/OpenSim/Framework/Data.MySQL/MySQLInventoryData.cs
index ded584e..f303a6b 100644
--- a/OpenSim/Framework/Data.MySQL/MySQLInventoryData.cs
+++ b/OpenSim/Framework/Data.MySQL/MySQLInventoryData.cs
@@ -26,13 +26,10 @@
26* 26*
27*/ 27*/
28using System; 28using System;
29using System.IO;
30using System.Data;
31using System.Collections.Generic; 29using System.Collections.Generic;
32using libsecondlife; 30using libsecondlife;
33using OpenSim.Framework;
34using OpenSim.Framework.Console;
35using MySql.Data.MySqlClient; 31using MySql.Data.MySqlClient;
32using OpenSim.Framework.Console;
36 33
37namespace OpenSim.Framework.Data.MySQL 34namespace OpenSim.Framework.Data.MySQL
38{ 35{
@@ -59,7 +56,9 @@ namespace OpenSim.Framework.Data.MySQL
59 string settingPooling = GridDataMySqlFile.ParseFileReadValue("pooling"); 56 string settingPooling = GridDataMySqlFile.ParseFileReadValue("pooling");
60 string settingPort = GridDataMySqlFile.ParseFileReadValue("port"); 57 string settingPort = GridDataMySqlFile.ParseFileReadValue("port");
61 58
62 database = new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling, settingPort); 59 database =
60 new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling,
61 settingPort);
63 TestTables(database.Connection); 62 TestTables(database.Connection);
64 } 63 }
65 64
@@ -99,7 +98,6 @@ namespace OpenSim.Framework.Data.MySQL
99 98
100 private void TestTables(MySqlConnection conn) 99 private void TestTables(MySqlConnection conn)
101 { 100 {
102
103 Dictionary<string, string> tableList = new Dictionary<string, string>(); 101 Dictionary<string, string> tableList = new Dictionary<string, string>();
104 102
105 tableList["inventoryfolders"] = null; 103 tableList["inventoryfolders"] = null;
@@ -110,6 +108,7 @@ namespace OpenSim.Framework.Data.MySQL
110 UpgradeFoldersTable(tableList["inventoryfolders"]); 108 UpgradeFoldersTable(tableList["inventoryfolders"]);
111 UpgradeItemsTable(tableList["inventoryitems"]); 109 UpgradeItemsTable(tableList["inventoryitems"]);
112 } 110 }
111
113 #endregion 112 #endregion
114 113
115 /// <summary> 114 /// <summary>
@@ -151,11 +150,13 @@ namespace OpenSim.Framework.Data.MySQL
151 { 150 {
152 List<InventoryItemBase> items = new List<InventoryItemBase>(); 151 List<InventoryItemBase> items = new List<InventoryItemBase>();
153 152
154 MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryitems WHERE parentFolderID = ?uuid", database.Connection); 153 MySqlCommand result =
154 new MySqlCommand("SELECT * FROM inventoryitems WHERE parentFolderID = ?uuid",
155 database.Connection);
155 result.Parameters.AddWithValue("?uuid", folderID.ToStringHyphenated()); 156 result.Parameters.AddWithValue("?uuid", folderID.ToStringHyphenated());
156 MySqlDataReader reader = result.ExecuteReader(); 157 MySqlDataReader reader = result.ExecuteReader();
157 158
158 while(reader.Read()) 159 while (reader.Read())
159 items.Add(readInventoryItem(reader)); 160 items.Add(readInventoryItem(reader));
160 161
161 reader.Close(); 162 reader.Close();
@@ -183,13 +184,16 @@ namespace OpenSim.Framework.Data.MySQL
183 { 184 {
184 lock (database) 185 lock (database)
185 { 186 {
186 MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE parentFolderID = ?zero AND agentID = ?uuid", database.Connection); 187 MySqlCommand result =
188 new MySqlCommand(
189 "SELECT * FROM inventoryfolders WHERE parentFolderID = ?zero AND agentID = ?uuid",
190 database.Connection);
187 result.Parameters.AddWithValue("?uuid", user.ToStringHyphenated()); 191 result.Parameters.AddWithValue("?uuid", user.ToStringHyphenated());
188 result.Parameters.AddWithValue("?zero", LLUUID.Zero.ToStringHyphenated()); 192 result.Parameters.AddWithValue("?zero", LLUUID.Zero.ToStringHyphenated());
189 MySqlDataReader reader = result.ExecuteReader(); 193 MySqlDataReader reader = result.ExecuteReader();
190 194
191 List<InventoryFolderBase> items = new List<InventoryFolderBase>(); 195 List<InventoryFolderBase> items = new List<InventoryFolderBase>();
192 while(reader.Read()) 196 while (reader.Read())
193 items.Add(readInventoryFolder(reader)); 197 items.Add(readInventoryFolder(reader));
194 198
195 199
@@ -218,17 +222,21 @@ namespace OpenSim.Framework.Data.MySQL
218 { 222 {
219 lock (database) 223 lock (database)
220 { 224 {
221 MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE parentFolderID = ?zero AND agentID = ?uuid", database.Connection); 225 MySqlCommand result =
226 new MySqlCommand(
227 "SELECT * FROM inventoryfolders WHERE parentFolderID = ?zero AND agentID = ?uuid",
228 database.Connection);
222 result.Parameters.AddWithValue("?uuid", user.ToStringHyphenated()); 229 result.Parameters.AddWithValue("?uuid", user.ToStringHyphenated());
223 result.Parameters.AddWithValue("?zero", LLUUID.Zero.ToStringHyphenated()); 230 result.Parameters.AddWithValue("?zero", LLUUID.Zero.ToStringHyphenated());
224 231
225 MySqlDataReader reader = result.ExecuteReader(); 232 MySqlDataReader reader = result.ExecuteReader();
226 233
227 List<InventoryFolderBase> items = new List<InventoryFolderBase>(); 234 List<InventoryFolderBase> items = new List<InventoryFolderBase>();
228 while(reader.Read()) 235 while (reader.Read())
229 items.Add(readInventoryFolder(reader)); 236 items.Add(readInventoryFolder(reader));
230 237
231 InventoryFolderBase rootFolder = items[0]; //should only be one folder with parent set to zero (the root one). 238 InventoryFolderBase rootFolder = items[0];
239 //should only be one folder with parent set to zero (the root one).
232 reader.Close(); 240 reader.Close();
233 result.Dispose(); 241 result.Dispose();
234 242
@@ -254,13 +262,15 @@ namespace OpenSim.Framework.Data.MySQL
254 { 262 {
255 lock (database) 263 lock (database)
256 { 264 {
257 MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE parentFolderID = ?uuid", database.Connection); 265 MySqlCommand result =
266 new MySqlCommand("SELECT * FROM inventoryfolders WHERE parentFolderID = ?uuid",
267 database.Connection);
258 result.Parameters.AddWithValue("?uuid", parentID.ToStringHyphenated()); 268 result.Parameters.AddWithValue("?uuid", parentID.ToStringHyphenated());
259 MySqlDataReader reader = result.ExecuteReader(); 269 MySqlDataReader reader = result.ExecuteReader();
260 270
261 List<InventoryFolderBase> items = new List<InventoryFolderBase>(); 271 List<InventoryFolderBase> items = new List<InventoryFolderBase>();
262 272
263 while(reader.Read()) 273 while (reader.Read())
264 items.Add(readInventoryFolder(reader)); 274 items.Add(readInventoryFolder(reader));
265 275
266 reader.Close(); 276 reader.Close();
@@ -288,19 +298,19 @@ namespace OpenSim.Framework.Data.MySQL
288 { 298 {
289 InventoryItemBase item = new InventoryItemBase(); 299 InventoryItemBase item = new InventoryItemBase();
290 300
291 item.inventoryID = new LLUUID((string)reader["inventoryID"]); 301 item.inventoryID = new LLUUID((string) reader["inventoryID"]);
292 item.assetID = new LLUUID((string)reader["assetID"]); 302 item.assetID = new LLUUID((string) reader["assetID"]);
293 item.assetType = (int)reader["assetType"]; 303 item.assetType = (int) reader["assetType"];
294 item.parentFolderID = new LLUUID((string)reader["parentFolderID"]); 304 item.parentFolderID = new LLUUID((string) reader["parentFolderID"]);
295 item.avatarID = new LLUUID((string)reader["avatarID"]); 305 item.avatarID = new LLUUID((string) reader["avatarID"]);
296 item.inventoryName = (string)reader["inventoryName"]; 306 item.inventoryName = (string) reader["inventoryName"];
297 item.inventoryDescription = (string)reader["inventoryDescription"]; 307 item.inventoryDescription = (string) reader["inventoryDescription"];
298 item.inventoryNextPermissions = (uint)reader["inventoryNextPermissions"]; 308 item.inventoryNextPermissions = (uint) reader["inventoryNextPermissions"];
299 item.inventoryCurrentPermissions = (uint)reader["inventoryCurrentPermissions"]; 309 item.inventoryCurrentPermissions = (uint) reader["inventoryCurrentPermissions"];
300 item.invType = (int)reader["invType"]; 310 item.invType = (int) reader["invType"];
301 item.creatorsID = new LLUUID((string)reader["creatorID"]); 311 item.creatorsID = new LLUUID((string) reader["creatorID"]);
302 item.inventoryBasePermissions = (uint)reader["inventoryBasePermissions"]; 312 item.inventoryBasePermissions = (uint) reader["inventoryBasePermissions"];
303 item.inventoryEveryOnePermissions = (uint)reader["inventoryEveryOnePermissions"]; 313 item.inventoryEveryOnePermissions = (uint) reader["inventoryEveryOnePermissions"];
304 return item; 314 return item;
305 } 315 }
306 catch (MySqlException e) 316 catch (MySqlException e)
@@ -324,12 +334,13 @@ namespace OpenSim.Framework.Data.MySQL
324 { 334 {
325 Dictionary<string, string> param = new Dictionary<string, string>(); 335 Dictionary<string, string> param = new Dictionary<string, string>();
326 336
327 MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryitems WHERE inventoryID = ?uuid", database.Connection); 337 MySqlCommand result =
338 new MySqlCommand("SELECT * FROM inventoryitems WHERE inventoryID = ?uuid", database.Connection);
328 result.Parameters.AddWithValue("?uuid", itemID.ToStringHyphenated()); 339 result.Parameters.AddWithValue("?uuid", itemID.ToStringHyphenated());
329 MySqlDataReader reader = result.ExecuteReader(); 340 MySqlDataReader reader = result.ExecuteReader();
330 341
331 InventoryItemBase item = null; 342 InventoryItemBase item = null;
332 if(reader.Read()) 343 if (reader.Read())
333 item = readInventoryItem(reader); 344 item = readInventoryItem(reader);
334 345
335 reader.Close(); 346 reader.Close();
@@ -356,12 +367,12 @@ namespace OpenSim.Framework.Data.MySQL
356 try 367 try
357 { 368 {
358 InventoryFolderBase folder = new InventoryFolderBase(); 369 InventoryFolderBase folder = new InventoryFolderBase();
359 folder.agentID = new LLUUID((string)reader["agentID"]); 370 folder.agentID = new LLUUID((string) reader["agentID"]);
360 folder.parentID = new LLUUID((string)reader["parentFolderID"]); 371 folder.parentID = new LLUUID((string) reader["parentFolderID"]);
361 folder.folderID = new LLUUID((string)reader["folderID"]); 372 folder.folderID = new LLUUID((string) reader["folderID"]);
362 folder.name = (string)reader["folderName"]; 373 folder.name = (string) reader["folderName"];
363 folder.type = (short)reader["type"]; 374 folder.type = (short) reader["type"];
364 folder.version = (ushort)((int)reader["version"]); 375 folder.version = (ushort) ((int) reader["version"]);
365 return folder; 376 return folder;
366 } 377 }
367 catch (Exception e) 378 catch (Exception e)
@@ -384,7 +395,8 @@ namespace OpenSim.Framework.Data.MySQL
384 { 395 {
385 lock (database) 396 lock (database)
386 { 397 {
387 MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE folderID = ?uuid", database.Connection); 398 MySqlCommand result =
399 new MySqlCommand("SELECT * FROM inventoryfolders WHERE folderID = ?uuid", database.Connection);
388 result.Parameters.AddWithValue("?uuid", folderID.ToStringHyphenated()); 400 result.Parameters.AddWithValue("?uuid", folderID.ToStringHyphenated());
389 MySqlDataReader reader = result.ExecuteReader(); 401 MySqlDataReader reader = result.ExecuteReader();
390 402
@@ -410,8 +422,10 @@ namespace OpenSim.Framework.Data.MySQL
410 /// <param name="item">The inventory item</param> 422 /// <param name="item">The inventory item</param>
411 public void addInventoryItem(InventoryItemBase item) 423 public void addInventoryItem(InventoryItemBase item)
412 { 424 {
413 string sql = "REPLACE INTO inventoryitems (inventoryID, assetID, assetType, parentFolderID, avatarID, inventoryName, inventoryDescription, inventoryNextPermissions, inventoryCurrentPermissions, invType, creatorID, inventoryBasePermissions, inventoryEveryOnePermissions) VALUES "; 425 string sql =
414 sql += "(?inventoryID, ?assetID, ?assetType, ?parentFolderID, ?avatarID, ?inventoryName, ?inventoryDescription, ?inventoryNextPermissions, ?inventoryCurrentPermissions, ?invType, ?creatorID, ?inventoryBasePermissions, ?inventoryEveryOnePermissions)"; 426 "REPLACE INTO inventoryitems (inventoryID, assetID, assetType, parentFolderID, avatarID, inventoryName, inventoryDescription, inventoryNextPermissions, inventoryCurrentPermissions, invType, creatorID, inventoryBasePermissions, inventoryEveryOnePermissions) VALUES ";
427 sql +=
428 "(?inventoryID, ?assetID, ?assetType, ?parentFolderID, ?avatarID, ?inventoryName, ?inventoryDescription, ?inventoryNextPermissions, ?inventoryCurrentPermissions, ?invType, ?creatorID, ?inventoryBasePermissions, ?inventoryEveryOnePermissions)";
415 429
416 try 430 try
417 { 431 {
@@ -424,7 +438,8 @@ namespace OpenSim.Framework.Data.MySQL
424 result.Parameters.AddWithValue("?inventoryName", item.inventoryName); 438 result.Parameters.AddWithValue("?inventoryName", item.inventoryName);
425 result.Parameters.AddWithValue("?inventoryDescription", item.inventoryDescription); 439 result.Parameters.AddWithValue("?inventoryDescription", item.inventoryDescription);
426 result.Parameters.AddWithValue("?inventoryNextPermissions", item.inventoryNextPermissions.ToString()); 440 result.Parameters.AddWithValue("?inventoryNextPermissions", item.inventoryNextPermissions.ToString());
427 result.Parameters.AddWithValue("?inventoryCurrentPermissions", item.inventoryCurrentPermissions.ToString()); 441 result.Parameters.AddWithValue("?inventoryCurrentPermissions",
442 item.inventoryCurrentPermissions.ToString());
428 result.Parameters.AddWithValue("?invType", item.invType); 443 result.Parameters.AddWithValue("?invType", item.invType);
429 result.Parameters.AddWithValue("?creatorID", item.creatorsID.ToStringHyphenated()); 444 result.Parameters.AddWithValue("?creatorID", item.creatorsID.ToStringHyphenated());
430 result.Parameters.AddWithValue("?inventoryBasePermissions", item.inventoryBasePermissions); 445 result.Parameters.AddWithValue("?inventoryBasePermissions", item.inventoryBasePermissions);
@@ -455,7 +470,8 @@ namespace OpenSim.Framework.Data.MySQL
455 { 470 {
456 try 471 try
457 { 472 {
458 MySqlCommand cmd = new MySqlCommand("DELETE FROM inventoryitems WHERE inventoryID=?uuid", database.Connection); 473 MySqlCommand cmd =
474 new MySqlCommand("DELETE FROM inventoryitems WHERE inventoryID=?uuid", database.Connection);
459 cmd.Parameters.AddWithValue("?uuid", itemID.ToStringHyphenated()); 475 cmd.Parameters.AddWithValue("?uuid", itemID.ToStringHyphenated());
460 cmd.ExecuteNonQuery(); 476 cmd.ExecuteNonQuery();
461 } 477 }
@@ -472,7 +488,8 @@ namespace OpenSim.Framework.Data.MySQL
472 /// <param name="folder">Folder to create</param> 488 /// <param name="folder">Folder to create</param>
473 public void addInventoryFolder(InventoryFolderBase folder) 489 public void addInventoryFolder(InventoryFolderBase folder)
474 { 490 {
475 string sql = "REPLACE INTO inventoryfolders (folderID, agentID, parentFolderID, folderName, type, version) VALUES "; 491 string sql =
492 "REPLACE INTO inventoryfolders (folderID, agentID, parentFolderID, folderName, type, version) VALUES ";
476 sql += "(?folderID, ?agentID, ?parentFolderID, ?folderName, ?type, ?version)"; 493 sql += "(?folderID, ?agentID, ?parentFolderID, ?folderName, ?type, ?version)";
477 494
478 MySqlCommand cmd = new MySqlCommand(sql, database.Connection); 495 MySqlCommand cmd = new MySqlCommand(sql, database.Connection);
@@ -480,9 +497,9 @@ namespace OpenSim.Framework.Data.MySQL
480 cmd.Parameters.AddWithValue("?agentID", folder.agentID.ToStringHyphenated()); 497 cmd.Parameters.AddWithValue("?agentID", folder.agentID.ToStringHyphenated());
481 cmd.Parameters.AddWithValue("?parentFolderID", folder.parentID.ToStringHyphenated()); 498 cmd.Parameters.AddWithValue("?parentFolderID", folder.parentID.ToStringHyphenated());
482 cmd.Parameters.AddWithValue("?folderName", folder.name); 499 cmd.Parameters.AddWithValue("?folderName", folder.name);
483 cmd.Parameters.AddWithValue("?type", (short)folder.type); 500 cmd.Parameters.AddWithValue("?type", (short) folder.type);
484 cmd.Parameters.AddWithValue("?version", folder.version); 501 cmd.Parameters.AddWithValue("?version", folder.version);
485 502
486 try 503 try
487 { 504 {
488 cmd.ExecuteNonQuery(); 505 cmd.ExecuteNonQuery();
@@ -515,7 +532,7 @@ namespace OpenSim.Framework.Data.MySQL
515 foreach (InventoryFolderBase f in subfolderList) 532 foreach (InventoryFolderBase f in subfolderList)
516 folders.Add(f); 533 folders.Add(f);
517 } 534 }
518 535
519 /// <summary> 536 /// <summary>
520 /// Returns all child folders in the hierarchy from the parent folder and down 537 /// Returns all child folders in the hierarchy from the parent folder and down
521 /// </summary> 538 /// </summary>
@@ -536,7 +553,8 @@ namespace OpenSim.Framework.Data.MySQL
536 { 553 {
537 try 554 try
538 { 555 {
539 MySqlCommand cmd = new MySqlCommand("DELETE FROM inventoryfolders WHERE folderID=?uuid", database.Connection); 556 MySqlCommand cmd =
557 new MySqlCommand("DELETE FROM inventoryfolders WHERE folderID=?uuid", database.Connection);
540 cmd.Parameters.AddWithValue("?uuid", folderID.ToStringHyphenated()); 558 cmd.Parameters.AddWithValue("?uuid", folderID.ToStringHyphenated());
541 cmd.ExecuteNonQuery(); 559 cmd.ExecuteNonQuery();
542 } 560 }
@@ -551,7 +569,8 @@ namespace OpenSim.Framework.Data.MySQL
551 { 569 {
552 try 570 try
553 { 571 {
554 MySqlCommand cmd = new MySqlCommand("DELETE FROM inventoryitems WHERE parentFolderID=?uuid", database.Connection); 572 MySqlCommand cmd =
573 new MySqlCommand("DELETE FROM inventoryitems WHERE parentFolderID=?uuid", database.Connection);
555 cmd.Parameters.AddWithValue("?uuid", folderID.ToStringHyphenated()); 574 cmd.Parameters.AddWithValue("?uuid", folderID.ToStringHyphenated());
556 cmd.ExecuteNonQuery(); 575 cmd.ExecuteNonQuery();
557 } 576 }
@@ -586,4 +605,4 @@ namespace OpenSim.Framework.Data.MySQL
586 } 605 }
587 } 606 }
588 } 607 }
589} 608} \ No newline at end of file
diff --git a/OpenSim/Framework/Data.MySQL/MySQLLogData.cs b/OpenSim/Framework/Data.MySQL/MySQLLogData.cs
index bfb4b48..e8775a1 100644
--- a/OpenSim/Framework/Data.MySQL/MySQLLogData.cs
+++ b/OpenSim/Framework/Data.MySQL/MySQLLogData.cs
@@ -25,14 +25,12 @@
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28using System;
29
30namespace OpenSim.Framework.Data.MySQL 28namespace OpenSim.Framework.Data.MySQL
31{ 29{
32 /// <summary> 30 /// <summary>
33 /// An interface to the log database for MySQL 31 /// An interface to the log database for MySQL
34 /// </summary> 32 /// </summary>
35 class MySQLLogData : ILogData 33 internal class MySQLLogData : ILogData
36 { 34 {
37 /// <summary> 35 /// <summary>
38 /// The database manager 36 /// The database manager
@@ -52,7 +50,9 @@ namespace OpenSim.Framework.Data.MySQL
52 string settingPooling = GridDataMySqlFile.ParseFileReadValue("pooling"); 50 string settingPooling = GridDataMySqlFile.ParseFileReadValue("pooling");
53 string settingPort = GridDataMySqlFile.ParseFileReadValue("port"); 51 string settingPort = GridDataMySqlFile.ParseFileReadValue("port");
54 52
55 database = new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling, settingPort); 53 database =
54 new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling,
55 settingPort);
56 } 56 }
57 57
58 /// <summary> 58 /// <summary>
@@ -64,7 +64,8 @@ namespace OpenSim.Framework.Data.MySQL
64 /// <param name="arguments">The arguments passed to the method</param> 64 /// <param name="arguments">The arguments passed to the method</param>
65 /// <param name="priority">How critical is this?</param> 65 /// <param name="priority">How critical is this?</param>
66 /// <param name="logMessage">The message to log</param> 66 /// <param name="logMessage">The message to log</param>
67 public void saveLog(string serverDaemon, string target, string methodCall, string arguments, int priority, string logMessage) 67 public void saveLog(string serverDaemon, string target, string methodCall, string arguments, int priority,
68 string logMessage)
68 { 69 {
69 try 70 try
70 { 71 {
@@ -102,4 +103,4 @@ namespace OpenSim.Framework.Data.MySQL
102 return "0.1"; 103 return "0.1";
103 } 104 }
104 } 105 }
105} 106} \ No newline at end of file
diff --git a/OpenSim/Framework/Data.MySQL/MySQLManager.cs b/OpenSim/Framework/Data.MySQL/MySQLManager.cs
index 8fcf68b..778da06 100644
--- a/OpenSim/Framework/Data.MySQL/MySQLManager.cs
+++ b/OpenSim/Framework/Data.MySQL/MySQLManager.cs
@@ -25,16 +25,14 @@
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28
28using System; 29using System;
29using System.IO; 30using System.Collections.Generic;
30using System.Data; 31using System.Data;
32using System.IO;
31using System.Reflection; 33using System.Reflection;
32using System.Collections.Generic;
33using libsecondlife; 34using libsecondlife;
34
35using MySql.Data.MySqlClient; 35using MySql.Data.MySqlClient;
36
37using OpenSim.Framework;
38using OpenSim.Framework.Console; 36using OpenSim.Framework.Console;
39 37
40namespace OpenSim.Framework.Data.MySQL 38namespace OpenSim.Framework.Data.MySQL
@@ -42,16 +40,17 @@ namespace OpenSim.Framework.Data.MySQL
42 /// <summary> 40 /// <summary>
43 /// A MySQL Database manager 41 /// A MySQL Database manager
44 /// </summary> 42 /// </summary>
45 class MySQLManager 43 internal class MySQLManager
46 { 44 {
47 /// <summary> 45 /// <summary>
48 /// The database connection object 46 /// The database connection object
49 /// </summary> 47 /// </summary>
50 MySqlConnection dbcon; 48 private MySqlConnection dbcon;
49
51 /// <summary> 50 /// <summary>
52 /// Connection string for ADO.net 51 /// Connection string for ADO.net
53 /// </summary> 52 /// </summary>
54 string connectionString; 53 private string connectionString;
55 54
56 /// <summary> 55 /// <summary>
57 /// Initialises and creates a new MySQL connection and maintains it. 56 /// Initialises and creates a new MySQL connection and maintains it.
@@ -61,11 +60,13 @@ namespace OpenSim.Framework.Data.MySQL
61 /// <param name="username">The username logging into the database</param> 60 /// <param name="username">The username logging into the database</param>
62 /// <param name="password">The password for the user logging in</param> 61 /// <param name="password">The password for the user logging in</param>
63 /// <param name="cpooling">Whether to use connection pooling or not, can be one of the following: 'yes', 'true', 'no' or 'false', if unsure use 'false'.</param> 62 /// <param name="cpooling">Whether to use connection pooling or not, can be one of the following: 'yes', 'true', 'no' or 'false', if unsure use 'false'.</param>
64 public MySQLManager(string hostname, string database, string username, string password, string cpooling, string port) 63 public MySQLManager(string hostname, string database, string username, string password, string cpooling,
64 string port)
65 { 65 {
66 try 66 try
67 { 67 {
68 connectionString = "Server=" + hostname + ";Port=" + port + ";Database=" + database + ";User ID=" + username + ";Password=" + password + ";Pooling=" + cpooling + ";"; 68 connectionString = "Server=" + hostname + ";Port=" + port + ";Database=" + database + ";User ID=" +
69 username + ";Password=" + password + ";Pooling=" + cpooling + ";";
69 dbcon = new MySqlConnection(connectionString); 70 dbcon = new MySqlConnection(connectionString);
70 71
71 dbcon.Open(); 72 dbcon.Open();
@@ -123,15 +124,17 @@ namespace OpenSim.Framework.Data.MySQL
123 /// <returns>A string containing the DB provider</returns> 124 /// <returns>A string containing the DB provider</returns>
124 public string getVersion() 125 public string getVersion()
125 { 126 {
126 System.Reflection.Module module = this.GetType().Module; 127 Module module = GetType().Module;
127 string dllName = module.Assembly.ManifestModule.Name; 128 string dllName = module.Assembly.ManifestModule.Name;
128 Version dllVersion = module.Assembly.GetName().Version; 129 Version dllVersion = module.Assembly.GetName().Version;
129 130
130 131
131 return string.Format("{0}.{1}.{2}.{3}", dllVersion.Major, dllVersion.Minor, dllVersion.Build, dllVersion.Revision); 132 return
133 string.Format("{0}.{1}.{2}.{3}", dllVersion.Major, dllVersion.Minor, dllVersion.Build,
134 dllVersion.Revision);
132 } 135 }
133 136
134 137
135 /// <summary> 138 /// <summary>
136 /// Extract a named string resource from the embedded resources 139 /// Extract a named string resource from the embedded resources
137 /// </summary> 140 /// </summary>
@@ -139,7 +142,7 @@ namespace OpenSim.Framework.Data.MySQL
139 /// <returns>string contained within the embedded resource</returns> 142 /// <returns>string contained within the embedded resource</returns>
140 private string getResourceString(string name) 143 private string getResourceString(string name)
141 { 144 {
142 Assembly assem = this.GetType().Assembly; 145 Assembly assem = GetType().Assembly;
143 string[] names = assem.GetManifestResourceNames(); 146 string[] names = assem.GetManifestResourceNames();
144 147
145 foreach (string s in names) 148 foreach (string s in names)
@@ -173,7 +176,10 @@ namespace OpenSim.Framework.Data.MySQL
173 { 176 {
174 lock (dbcon) 177 lock (dbcon)
175 { 178 {
176 MySqlCommand tablesCmd = new MySqlCommand("SELECT TABLE_NAME, TABLE_COMMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA=?dbname", dbcon); 179 MySqlCommand tablesCmd =
180 new MySqlCommand(
181 "SELECT TABLE_NAME, TABLE_COMMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA=?dbname",
182 dbcon);
177 tablesCmd.Parameters.AddWithValue("?dbname", dbcon.Database); 183 tablesCmd.Parameters.AddWithValue("?dbname", dbcon.Database);
178 using (MySqlDataReader tables = tablesCmd.ExecuteReader()) 184 using (MySqlDataReader tables = tablesCmd.ExecuteReader())
179 { 185 {
@@ -181,9 +187,9 @@ namespace OpenSim.Framework.Data.MySQL
181 { 187 {
182 try 188 try
183 { 189 {
184 string tableName = (string)tables["TABLE_NAME"]; 190 string tableName = (string) tables["TABLE_NAME"];
185 string comment = (string)tables["TABLE_COMMENT"]; 191 string comment = (string) tables["TABLE_COMMENT"];
186 if(tableList.ContainsKey(tableName)) 192 if (tableList.ContainsKey(tableName))
187 tableList[tableName] = comment; 193 tableList[tableName] = comment;
188 } 194 }
189 catch (Exception e) 195 catch (Exception e)
@@ -198,7 +204,7 @@ namespace OpenSim.Framework.Data.MySQL
198 204
199 205
200 // at some time this code should be cleaned up 206 // at some time this code should be cleaned up
201 207
202 /// <summary> 208 /// <summary>
203 /// Runs a query with protection against SQL Injection by using parameterised input. 209 /// Runs a query with protection against SQL Injection by using parameterised input.
204 /// </summary> 210 /// </summary>
@@ -209,14 +215,14 @@ namespace OpenSim.Framework.Data.MySQL
209 { 215 {
210 try 216 try
211 { 217 {
212 MySqlCommand dbcommand = (MySqlCommand)dbcon.CreateCommand(); 218 MySqlCommand dbcommand = (MySqlCommand) dbcon.CreateCommand();
213 dbcommand.CommandText = sql; 219 dbcommand.CommandText = sql;
214 foreach (KeyValuePair<string, string> param in parameters) 220 foreach (KeyValuePair<string, string> param in parameters)
215 { 221 {
216 dbcommand.Parameters.AddWithValue(param.Key, param.Value); 222 dbcommand.Parameters.AddWithValue(param.Key, param.Value);
217 } 223 }
218 224
219 return (IDbCommand)dbcommand; 225 return (IDbCommand) dbcommand;
220 } 226 }
221 catch 227 catch
222 { 228 {
@@ -227,7 +233,9 @@ namespace OpenSim.Framework.Data.MySQL
227 { 233 {
228 dbcon.Close(); 234 dbcon.Close();
229 } 235 }
230 catch { } 236 catch
237 {
238 }
231 239
232 // Try reopen it 240 // Try reopen it
233 try 241 try
@@ -243,14 +251,14 @@ namespace OpenSim.Framework.Data.MySQL
243 // Run the query again 251 // Run the query again
244 try 252 try
245 { 253 {
246 MySqlCommand dbcommand = (MySqlCommand)dbcon.CreateCommand(); 254 MySqlCommand dbcommand = (MySqlCommand) dbcon.CreateCommand();
247 dbcommand.CommandText = sql; 255 dbcommand.CommandText = sql;
248 foreach (KeyValuePair<string, string> param in parameters) 256 foreach (KeyValuePair<string, string> param in parameters)
249 { 257 {
250 dbcommand.Parameters.AddWithValue(param.Key, param.Value); 258 dbcommand.Parameters.AddWithValue(param.Key, param.Value);
251 } 259 }
252 260
253 return (IDbCommand)dbcommand; 261 return (IDbCommand) dbcommand;
254 } 262 }
255 catch (Exception e) 263 catch (Exception e)
256 { 264 {
@@ -275,20 +283,20 @@ namespace OpenSim.Framework.Data.MySQL
275 { 283 {
276 // Region Main 284 // Region Main
277 retval.regionHandle = Convert.ToUInt64(reader["regionHandle"].ToString()); 285 retval.regionHandle = Convert.ToUInt64(reader["regionHandle"].ToString());
278 retval.regionName = (string)reader["regionName"]; 286 retval.regionName = (string) reader["regionName"];
279 retval.UUID = new LLUUID((string)reader["uuid"]); 287 retval.UUID = new LLUUID((string) reader["uuid"]);
280 288
281 // Secrets 289 // Secrets
282 retval.regionRecvKey = (string)reader["regionRecvKey"]; 290 retval.regionRecvKey = (string) reader["regionRecvKey"];
283 retval.regionSecret = (string)reader["regionSecret"]; 291 retval.regionSecret = (string) reader["regionSecret"];
284 retval.regionSendKey = (string)reader["regionSendKey"]; 292 retval.regionSendKey = (string) reader["regionSendKey"];
285 293
286 // Region Server 294 // Region Server
287 retval.regionDataURI = (string)reader["regionDataURI"]; 295 retval.regionDataURI = (string) reader["regionDataURI"];
288 retval.regionOnline = false; // Needs to be pinged before this can be set. 296 retval.regionOnline = false; // Needs to be pinged before this can be set.
289 retval.serverIP = (string)reader["serverIP"]; 297 retval.serverIP = (string) reader["serverIP"];
290 retval.serverPort = (uint)reader["serverPort"]; 298 retval.serverPort = (uint) reader["serverPort"];
291 retval.serverURI = (string)reader["serverURI"]; 299 retval.serverURI = (string) reader["serverURI"];
292 retval.httpPort = Convert.ToUInt32(reader["serverHttpPort"].ToString()); 300 retval.httpPort = Convert.ToUInt32(reader["serverHttpPort"].ToString());
293 retval.remotingPort = Convert.ToUInt32(reader["serverRemotingPort"].ToString()); 301 retval.remotingPort = Convert.ToUInt32(reader["serverRemotingPort"].ToString());
294 302
@@ -304,14 +312,14 @@ namespace OpenSim.Framework.Data.MySQL
304 retval.regionNorthOverrideHandle = Convert.ToUInt64(reader["northOverrideHandle"].ToString()); 312 retval.regionNorthOverrideHandle = Convert.ToUInt64(reader["northOverrideHandle"].ToString());
305 313
306 // Assets 314 // Assets
307 retval.regionAssetURI = (string)reader["regionAssetURI"]; 315 retval.regionAssetURI = (string) reader["regionAssetURI"];
308 retval.regionAssetRecvKey = (string)reader["regionAssetRecvKey"]; 316 retval.regionAssetRecvKey = (string) reader["regionAssetRecvKey"];
309 retval.regionAssetSendKey = (string)reader["regionAssetSendKey"]; 317 retval.regionAssetSendKey = (string) reader["regionAssetSendKey"];
310 318
311 // Userserver 319 // Userserver
312 retval.regionUserURI = (string)reader["regionUserURI"]; 320 retval.regionUserURI = (string) reader["regionUserURI"];
313 retval.regionUserRecvKey = (string)reader["regionUserRecvKey"]; 321 retval.regionUserRecvKey = (string) reader["regionUserRecvKey"];
314 retval.regionUserSendKey = (string)reader["regionUserSendKey"]; 322 retval.regionUserSendKey = (string) reader["regionUserSendKey"];
315 323
316 // World Map Addition 324 // World Map Addition
317 string tempRegionMap = reader["regionMapTexture"].ToString(); 325 string tempRegionMap = reader["regionMapTexture"].ToString();
@@ -341,17 +349,16 @@ namespace OpenSim.Framework.Data.MySQL
341 ReservationData retval = new ReservationData(); 349 ReservationData retval = new ReservationData();
342 if (reader.Read()) 350 if (reader.Read())
343 { 351 {
344 retval.gridRecvKey = (string)reader["gridRecvKey"]; 352 retval.gridRecvKey = (string) reader["gridRecvKey"];
345 retval.gridSendKey = (string)reader["gridSendKey"]; 353 retval.gridSendKey = (string) reader["gridSendKey"];
346 retval.reservationCompany = (string)reader["resCompany"]; 354 retval.reservationCompany = (string) reader["resCompany"];
347 retval.reservationMaxX = Convert.ToInt32(reader["resXMax"].ToString()); 355 retval.reservationMaxX = Convert.ToInt32(reader["resXMax"].ToString());
348 retval.reservationMaxY = Convert.ToInt32(reader["resYMax"].ToString()); 356 retval.reservationMaxY = Convert.ToInt32(reader["resYMax"].ToString());
349 retval.reservationMinX = Convert.ToInt32(reader["resXMin"].ToString()); 357 retval.reservationMinX = Convert.ToInt32(reader["resXMin"].ToString());
350 retval.reservationMinY = Convert.ToInt32(reader["resYMin"].ToString()); 358 retval.reservationMinY = Convert.ToInt32(reader["resYMin"].ToString());
351 retval.reservationName = (string)reader["resName"]; 359 retval.reservationName = (string) reader["resName"];
352 retval.status = Convert.ToInt32(reader["status"].ToString()) == 1; 360 retval.status = Convert.ToInt32(reader["status"].ToString()) == 1;
353 retval.userUUID = new LLUUID((string)reader["userUUID"]); 361 retval.userUUID = new LLUUID((string) reader["userUUID"]);
354
355 } 362 }
356 else 363 else
357 { 364 {
@@ -359,6 +366,7 @@ namespace OpenSim.Framework.Data.MySQL
359 } 366 }
360 return retval; 367 return retval;
361 } 368 }
369
362 /// <summary> 370 /// <summary>
363 /// Reads an agent row from a database reader 371 /// Reads an agent row from a database reader
364 /// </summary> 372 /// </summary>
@@ -371,12 +379,12 @@ namespace OpenSim.Framework.Data.MySQL
371 if (reader.Read()) 379 if (reader.Read())
372 { 380 {
373 // Agent IDs 381 // Agent IDs
374 retval.UUID = new LLUUID((string)reader["UUID"]); 382 retval.UUID = new LLUUID((string) reader["UUID"]);
375 retval.sessionID = new LLUUID((string)reader["sessionID"]); 383 retval.sessionID = new LLUUID((string) reader["sessionID"]);
376 retval.secureSessionID = new LLUUID((string)reader["secureSessionID"]); 384 retval.secureSessionID = new LLUUID((string) reader["secureSessionID"]);
377 385
378 // Agent Who? 386 // Agent Who?
379 retval.agentIP = (string)reader["agentIP"]; 387 retval.agentIP = (string) reader["agentIP"];
380 retval.agentPort = Convert.ToUInt32(reader["agentPort"].ToString()); 388 retval.agentPort = Convert.ToUInt32(reader["agentPort"].ToString());
381 retval.agentOnline = Convert.ToBoolean(reader["agentOnline"].ToString()); 389 retval.agentOnline = Convert.ToBoolean(reader["agentOnline"].ToString());
382 390
@@ -385,9 +393,9 @@ namespace OpenSim.Framework.Data.MySQL
385 retval.logoutTime = Convert.ToInt32(reader["logoutTime"].ToString()); 393 retval.logoutTime = Convert.ToInt32(reader["logoutTime"].ToString());
386 394
387 // Current position 395 // Current position
388 retval.currentRegion = (string)reader["currentRegion"]; 396 retval.currentRegion = (string) reader["currentRegion"];
389 retval.currentHandle = Convert.ToUInt64(reader["currentHandle"].ToString()); 397 retval.currentHandle = Convert.ToUInt64(reader["currentHandle"].ToString());
390 LLVector3.TryParse((string)reader["currentPos"], out retval.currentPos); 398 LLVector3.TryParse((string) reader["currentPos"], out retval.currentPos);
391 } 399 }
392 else 400 else
393 { 401 {
@@ -407,12 +415,12 @@ namespace OpenSim.Framework.Data.MySQL
407 415
408 if (reader.Read()) 416 if (reader.Read())
409 { 417 {
410 retval.UUID = new LLUUID((string)reader["UUID"]); 418 retval.UUID = new LLUUID((string) reader["UUID"]);
411 retval.username = (string)reader["username"]; 419 retval.username = (string) reader["username"];
412 retval.surname = (string)reader["lastname"]; 420 retval.surname = (string) reader["lastname"];
413 421
414 retval.passwordHash = (string)reader["passwordHash"]; 422 retval.passwordHash = (string) reader["passwordHash"];
415 retval.passwordSalt = (string)reader["passwordSalt"]; 423 retval.passwordSalt = (string) reader["passwordSalt"];
416 424
417 retval.homeRegion = Convert.ToUInt64(reader["homeRegion"].ToString()); 425 retval.homeRegion = Convert.ToUInt64(reader["homeRegion"].ToString());
418 retval.homeLocation = new LLVector3( 426 retval.homeLocation = new LLVector3(
@@ -427,18 +435,17 @@ namespace OpenSim.Framework.Data.MySQL
427 retval.created = Convert.ToInt32(reader["created"].ToString()); 435 retval.created = Convert.ToInt32(reader["created"].ToString());
428 retval.lastLogin = Convert.ToInt32(reader["lastLogin"].ToString()); 436 retval.lastLogin = Convert.ToInt32(reader["lastLogin"].ToString());
429 437
430 retval.userInventoryURI = (string)reader["userInventoryURI"]; 438 retval.userInventoryURI = (string) reader["userInventoryURI"];
431 retval.userAssetURI = (string)reader["userAssetURI"]; 439 retval.userAssetURI = (string) reader["userAssetURI"];
432 440
433 retval.profileCanDoMask = Convert.ToUInt32(reader["profileCanDoMask"].ToString()); 441 retval.profileCanDoMask = Convert.ToUInt32(reader["profileCanDoMask"].ToString());
434 retval.profileWantDoMask = Convert.ToUInt32(reader["profileWantDoMask"].ToString()); 442 retval.profileWantDoMask = Convert.ToUInt32(reader["profileWantDoMask"].ToString());
435 443
436 retval.profileAboutText = (string)reader["profileAboutText"]; 444 retval.profileAboutText = (string) reader["profileAboutText"];
437 retval.profileFirstText = (string)reader["profileFirstText"]; 445 retval.profileFirstText = (string) reader["profileFirstText"];
438
439 retval.profileImage = new LLUUID((string)reader["profileImage"]);
440 retval.profileFirstImage = new LLUUID((string)reader["profileFirstImage"]);
441 446
447 retval.profileImage = new LLUUID((string) reader["profileImage"]);
448 retval.profileFirstImage = new LLUUID((string) reader["profileFirstImage"]);
442 } 449 }
443 else 450 else
444 { 451 {
@@ -448,7 +455,6 @@ namespace OpenSim.Framework.Data.MySQL
448 } 455 }
449 456
450 457
451
452 /// <summary> 458 /// <summary>
453 /// Inserts a new row into the log database 459 /// Inserts a new row into the log database
454 /// </summary> 460 /// </summary>
@@ -459,7 +465,8 @@ namespace OpenSim.Framework.Data.MySQL
459 /// <param name="priority">How critical is this?</param> 465 /// <param name="priority">How critical is this?</param>
460 /// <param name="logMessage">Extra message info</param> 466 /// <param name="logMessage">Extra message info</param>
461 /// <returns>Saved successfully?</returns> 467 /// <returns>Saved successfully?</returns>
462 public bool insertLogRow(string serverDaemon, string target, string methodCall, string arguments, int priority, string logMessage) 468 public bool insertLogRow(string serverDaemon, string target, string methodCall, string arguments, int priority,
469 string logMessage)
463 { 470 {
464 string sql = "INSERT INTO logs (`target`, `server`, `method`, `arguments`, `priority`, `message`) VALUES "; 471 string sql = "INSERT INTO logs (`target`, `server`, `method`, `arguments`, `priority`, `message`) VALUES ";
465 sql += "(?target, ?server, ?method, ?arguments, ?priority, ?message)"; 472 sql += "(?target, ?server, ?method, ?arguments, ?priority, ?message)";
@@ -493,89 +500,97 @@ namespace OpenSim.Framework.Data.MySQL
493 } 500 }
494 501
495 502
496 /// <summary> 503 /// <summary>
497 /// Creates a new user and inserts it into the database 504 /// Creates a new user and inserts it into the database
498 /// </summary> 505 /// </summary>
499 /// <param name="uuid">User ID</param> 506 /// <param name="uuid">User ID</param>
500 /// <param name="username">First part of the login</param> 507 /// <param name="username">First part of the login</param>
501 /// <param name="lastname">Second part of the login</param> 508 /// <param name="lastname">Second part of the login</param>
502 /// <param name="passwordHash">A salted hash of the users password</param> 509 /// <param name="passwordHash">A salted hash of the users password</param>
503 /// <param name="passwordSalt">The salt used for the password hash</param> 510 /// <param name="passwordSalt">The salt used for the password hash</param>
504 /// <param name="homeRegion">A regionHandle of the users home region</param> 511 /// <param name="homeRegion">A regionHandle of the users home region</param>
505 /// <param name="homeLocX">Home region position vector</param> 512 /// <param name="homeLocX">Home region position vector</param>
506 /// <param name="homeLocY">Home region position vector</param> 513 /// <param name="homeLocY">Home region position vector</param>
507 /// <param name="homeLocZ">Home region position vector</param> 514 /// <param name="homeLocZ">Home region position vector</param>
508 /// <param name="homeLookAtX">Home region 'look at' vector</param> 515 /// <param name="homeLookAtX">Home region 'look at' vector</param>
509 /// <param name="homeLookAtY">Home region 'look at' vector</param> 516 /// <param name="homeLookAtY">Home region 'look at' vector</param>
510 /// <param name="homeLookAtZ">Home region 'look at' vector</param> 517 /// <param name="homeLookAtZ">Home region 'look at' vector</param>
511 /// <param name="created">Account created (unix timestamp)</param> 518 /// <param name="created">Account created (unix timestamp)</param>
512 /// <param name="lastlogin">Last login (unix timestamp)</param> 519 /// <param name="lastlogin">Last login (unix timestamp)</param>
513 /// <param name="inventoryURI">Users inventory URI</param> 520 /// <param name="inventoryURI">Users inventory URI</param>
514 /// <param name="assetURI">Users asset URI</param> 521 /// <param name="assetURI">Users asset URI</param>
515 /// <param name="canDoMask">I can do mask</param> 522 /// <param name="canDoMask">I can do mask</param>
516 /// <param name="wantDoMask">I want to do mask</param> 523 /// <param name="wantDoMask">I want to do mask</param>
517 /// <param name="aboutText">Profile text</param> 524 /// <param name="aboutText">Profile text</param>
518 /// <param name="firstText">Firstlife text</param> 525 /// <param name="firstText">Firstlife text</param>
519 /// <param name="profileImage">UUID for profile image</param> 526 /// <param name="profileImage">UUID for profile image</param>
520 /// <param name="firstImage">UUID for firstlife image</param> 527 /// <param name="firstImage">UUID for firstlife image</param>
521 /// <returns>Success?</returns> 528 /// <returns>Success?</returns>
522 public bool insertUserRow(libsecondlife.LLUUID uuid, string username, string lastname, string passwordHash, string passwordSalt, UInt64 homeRegion, float homeLocX, float homeLocY, float homeLocZ, 529 public bool insertUserRow(LLUUID uuid, string username, string lastname, string passwordHash,
523 float homeLookAtX, float homeLookAtY, float homeLookAtZ, int created, int lastlogin, string inventoryURI, string assetURI, uint canDoMask, uint wantDoMask, string aboutText, string firstText, 530 string passwordSalt, UInt64 homeRegion, float homeLocX, float homeLocY, float homeLocZ,
524 libsecondlife.LLUUID profileImage, libsecondlife.LLUUID firstImage) 531 float homeLookAtX, float homeLookAtY, float homeLookAtZ, int created, int lastlogin,
525 { 532 string inventoryURI, string assetURI, uint canDoMask, uint wantDoMask,
526 string sql = "INSERT INTO users (`UUID`, `username`, `lastname`, `passwordHash`, `passwordSalt`, `homeRegion`, "; 533 string aboutText, string firstText,
527 sql += "`homeLocationX`, `homeLocationY`, `homeLocationZ`, `homeLookAtX`, `homeLookAtY`, `homeLookAtZ`, `created`, "; 534 LLUUID profileImage, LLUUID firstImage)
528 sql += "`lastLogin`, `userInventoryURI`, `userAssetURI`, `profileCanDoMask`, `profileWantDoMask`, `profileAboutText`, "; 535 {
529 sql += "`profileFirstText`, `profileImage`, `profileFirstImage`) VALUES "; 536 string sql =
530 537 "INSERT INTO users (`UUID`, `username`, `lastname`, `passwordHash`, `passwordSalt`, `homeRegion`, ";
531 sql += "(?UUID, ?username, ?lastname, ?passwordHash, ?passwordSalt, ?homeRegion, "; 538 sql +=
532 sql += "?homeLocationX, ?homeLocationY, ?homeLocationZ, ?homeLookAtX, ?homeLookAtY, ?homeLookAtZ, ?created, "; 539 "`homeLocationX`, `homeLocationY`, `homeLocationZ`, `homeLookAtX`, `homeLookAtY`, `homeLookAtZ`, `created`, ";
533 sql += "?lastLogin, ?userInventoryURI, ?userAssetURI, ?profileCanDoMask, ?profileWantDoMask, ?profileAboutText, "; 540 sql +=
534 sql += "?profileFirstText, ?profileImage, ?profileFirstImage)"; 541 "`lastLogin`, `userInventoryURI`, `userAssetURI`, `profileCanDoMask`, `profileWantDoMask`, `profileAboutText`, ";
535 542 sql += "`profileFirstText`, `profileImage`, `profileFirstImage`) VALUES ";
536 Dictionary<string, string> parameters = new Dictionary<string, string>(); 543
537 parameters["?UUID"] = uuid.ToStringHyphenated(); 544 sql += "(?UUID, ?username, ?lastname, ?passwordHash, ?passwordSalt, ?homeRegion, ";
538 parameters["?username"] = username.ToString(); 545 sql +=
539 parameters["?lastname"] = lastname.ToString(); 546 "?homeLocationX, ?homeLocationY, ?homeLocationZ, ?homeLookAtX, ?homeLookAtY, ?homeLookAtZ, ?created, ";
540 parameters["?passwordHash"] = passwordHash.ToString(); 547 sql +=
541 parameters["?passwordSalt"] = passwordSalt.ToString(); 548 "?lastLogin, ?userInventoryURI, ?userAssetURI, ?profileCanDoMask, ?profileWantDoMask, ?profileAboutText, ";
542 parameters["?homeRegion"] = homeRegion.ToString(); 549 sql += "?profileFirstText, ?profileImage, ?profileFirstImage)";
543 parameters["?homeLocationX"] = homeLocX.ToString(); 550
544 parameters["?homeLocationY"] = homeLocY.ToString(); 551 Dictionary<string, string> parameters = new Dictionary<string, string>();
545 parameters["?homeLocationZ"] = homeLocZ.ToString(); 552 parameters["?UUID"] = uuid.ToStringHyphenated();
546 parameters["?homeLookAtX"] = homeLookAtX.ToString(); 553 parameters["?username"] = username.ToString();
547 parameters["?homeLookAtY"] = homeLookAtY.ToString(); 554 parameters["?lastname"] = lastname.ToString();
548 parameters["?homeLookAtZ"] = homeLookAtZ.ToString(); 555 parameters["?passwordHash"] = passwordHash.ToString();
549 parameters["?created"] = created.ToString(); 556 parameters["?passwordSalt"] = passwordSalt.ToString();
550 parameters["?lastLogin"] = lastlogin.ToString(); 557 parameters["?homeRegion"] = homeRegion.ToString();
551 parameters["?userInventoryURI"] = ""; 558 parameters["?homeLocationX"] = homeLocX.ToString();
552 parameters["?userAssetURI"] = ""; 559 parameters["?homeLocationY"] = homeLocY.ToString();
553 parameters["?profileCanDoMask"] = "0"; 560 parameters["?homeLocationZ"] = homeLocZ.ToString();
554 parameters["?profileWantDoMask"] = "0"; 561 parameters["?homeLookAtX"] = homeLookAtX.ToString();
555 parameters["?profileAboutText"] = ""; 562 parameters["?homeLookAtY"] = homeLookAtY.ToString();
556 parameters["?profileFirstText"] = ""; 563 parameters["?homeLookAtZ"] = homeLookAtZ.ToString();
557 parameters["?profileImage"] = libsecondlife.LLUUID.Zero.ToStringHyphenated(); 564 parameters["?created"] = created.ToString();
558 parameters["?profileFirstImage"] = libsecondlife.LLUUID.Zero.ToStringHyphenated(); 565 parameters["?lastLogin"] = lastlogin.ToString();
559 566 parameters["?userInventoryURI"] = "";
560 bool returnval = false; 567 parameters["?userAssetURI"] = "";
561 568 parameters["?profileCanDoMask"] = "0";
562 try 569 parameters["?profileWantDoMask"] = "0";
563 { 570 parameters["?profileAboutText"] = "";
564 IDbCommand result = Query(sql, parameters); 571 parameters["?profileFirstText"] = "";
565 572 parameters["?profileImage"] = LLUUID.Zero.ToStringHyphenated();
566 if (result.ExecuteNonQuery() == 1) 573 parameters["?profileFirstImage"] = LLUUID.Zero.ToStringHyphenated();
567 returnval = true; 574
568 575 bool returnval = false;
569 result.Dispose(); 576
570 } 577 try
571 catch (Exception e) 578 {
572 { 579 IDbCommand result = Query(sql, parameters);
573 MainLog.Instance.Error(e.ToString()); 580
574 return false; 581 if (result.ExecuteNonQuery() == 1)
575 } 582 returnval = true;
576 583
577 return returnval; 584 result.Dispose();
578 } 585 }
586 catch (Exception e)
587 {
588 MainLog.Instance.Error(e.ToString());
589 return false;
590 }
591
592 return returnval;
593 }
579 594
580 595
581 /// <summary> 596 /// <summary>
@@ -585,13 +600,18 @@ namespace OpenSim.Framework.Data.MySQL
585 /// <returns>Success?</returns> 600 /// <returns>Success?</returns>
586 public bool insertRegion(RegionProfileData regiondata) 601 public bool insertRegion(RegionProfileData regiondata)
587 { 602 {
588 string sql = "REPLACE INTO regions (regionHandle, regionName, uuid, regionRecvKey, regionSecret, regionSendKey, regionDataURI, "; 603 string sql =
589 sql += "serverIP, serverPort, serverURI, locX, locY, locZ, eastOverrideHandle, westOverrideHandle, southOverrideHandle, northOverrideHandle, regionAssetURI, regionAssetRecvKey, "; 604 "REPLACE INTO regions (regionHandle, regionName, uuid, regionRecvKey, regionSecret, regionSendKey, regionDataURI, ";
590 sql += "regionAssetSendKey, regionUserURI, regionUserRecvKey, regionUserSendKey, regionMapTexture, serverHttpPort, serverRemotingPort) VALUES "; 605 sql +=
606 "serverIP, serverPort, serverURI, locX, locY, locZ, eastOverrideHandle, westOverrideHandle, southOverrideHandle, northOverrideHandle, regionAssetURI, regionAssetRecvKey, ";
607 sql +=
608 "regionAssetSendKey, regionUserURI, regionUserRecvKey, regionUserSendKey, regionMapTexture, serverHttpPort, serverRemotingPort) VALUES ";
591 609
592 sql += "(?regionHandle, ?regionName, ?uuid, ?regionRecvKey, ?regionSecret, ?regionSendKey, ?regionDataURI, "; 610 sql += "(?regionHandle, ?regionName, ?uuid, ?regionRecvKey, ?regionSecret, ?regionSendKey, ?regionDataURI, ";
593 sql += "?serverIP, ?serverPort, ?serverURI, ?locX, ?locY, ?locZ, ?eastOverrideHandle, ?westOverrideHandle, ?southOverrideHandle, ?northOverrideHandle, ?regionAssetURI, ?regionAssetRecvKey, "; 611 sql +=
594 sql += "?regionAssetSendKey, ?regionUserURI, ?regionUserRecvKey, ?regionUserSendKey, ?regionMapTexture, ?serverHttpPort, ?serverRemotingPort);"; 612 "?serverIP, ?serverPort, ?serverURI, ?locX, ?locY, ?locZ, ?eastOverrideHandle, ?westOverrideHandle, ?southOverrideHandle, ?northOverrideHandle, ?regionAssetURI, ?regionAssetRecvKey, ";
613 sql +=
614 "?regionAssetSendKey, ?regionUserURI, ?regionUserRecvKey, ?regionUserSendKey, ?regionMapTexture, ?serverHttpPort, ?serverRemotingPort);";
595 615
596 Dictionary<string, string> parameters = new Dictionary<string, string>(); 616 Dictionary<string, string> parameters = new Dictionary<string, string>();
597 617
@@ -626,7 +646,6 @@ namespace OpenSim.Framework.Data.MySQL
626 646
627 try 647 try
628 { 648 {
629
630 IDbCommand result = Query(sql, parameters); 649 IDbCommand result = Query(sql, parameters);
631 650
632 //Console.WriteLine(result.CommandText); 651 //Console.WriteLine(result.CommandText);
@@ -646,4 +665,4 @@ namespace OpenSim.Framework.Data.MySQL
646 return returnval; 665 return returnval;
647 } 666 }
648 } 667 }
649} 668} \ No newline at end of file
diff --git a/OpenSim/Framework/Data.MySQL/MySQLUserData.cs b/OpenSim/Framework/Data.MySQL/MySQLUserData.cs
index 27c9cf6..8846650 100644
--- a/OpenSim/Framework/Data.MySQL/MySQLUserData.cs
+++ b/OpenSim/Framework/Data.MySQL/MySQLUserData.cs
@@ -29,7 +29,6 @@ using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Data; 30using System.Data;
31using libsecondlife; 31using libsecondlife;
32using OpenSim.Framework;
33using OpenSim.Framework.Console; 32using OpenSim.Framework.Console;
34 33
35namespace OpenSim.Framework.Data.MySQL 34namespace OpenSim.Framework.Data.MySQL
@@ -37,7 +36,7 @@ namespace OpenSim.Framework.Data.MySQL
37 /// <summary> 36 /// <summary>
38 /// A database interface class to a user profile storage system 37 /// A database interface class to a user profile storage system
39 /// </summary> 38 /// </summary>
40 class MySQLUserData : IUserData 39 internal class MySQLUserData : IUserData
41 { 40 {
42 /// <summary> 41 /// <summary>
43 /// Database manager for MySQL 42 /// Database manager for MySQL
@@ -59,7 +58,9 @@ namespace OpenSim.Framework.Data.MySQL
59 string settingPooling = GridDataMySqlFile.ParseFileReadValue("pooling"); 58 string settingPooling = GridDataMySqlFile.ParseFileReadValue("pooling");
60 string settingPort = GridDataMySqlFile.ParseFileReadValue("port"); 59 string settingPort = GridDataMySqlFile.ParseFileReadValue("port");
61 60
62 database = new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling, settingPort); 61 database =
62 new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling,
63 settingPort);
63 } 64 }
64 65
65 /// <summary> 66 /// <summary>
@@ -88,11 +89,12 @@ namespace OpenSim.Framework.Data.MySQL
88 param["?first"] = user; 89 param["?first"] = user;
89 param["?second"] = last; 90 param["?second"] = last;
90 91
91 IDbCommand result = database.Query("SELECT * FROM users WHERE username = ?first AND lastname = ?second", param); 92 IDbCommand result =
93 database.Query("SELECT * FROM users WHERE username = ?first AND lastname = ?second", param);
92 IDataReader reader = result.ExecuteReader(); 94 IDataReader reader = result.ExecuteReader();
93 95
94 UserProfileData row = database.readUserRow(reader); 96 UserProfileData row = database.readUserRow(reader);
95 97
96 reader.Close(); 98 reader.Close();
97 result.Dispose(); 99 result.Dispose();
98 100
@@ -201,21 +203,25 @@ namespace OpenSim.Framework.Data.MySQL
201 /// <param name="user">The user profile to create</param> 203 /// <param name="user">The user profile to create</param>
202 public void AddNewUserProfile(UserProfileData user) 204 public void AddNewUserProfile(UserProfileData user)
203 { 205 {
204 try 206 try
205 { 207 {
206 lock (database) 208 lock (database)
207 { 209 {
208 database.insertUserRow(user.UUID, user.username, user.surname, user.passwordHash, user.passwordSalt, user.homeRegion, user.homeLocation.X, user.homeLocation.Y, user.homeLocation.Z, 210 database.insertUserRow(user.UUID, user.username, user.surname, user.passwordHash, user.passwordSalt,
209 user.homeLookAt.X, user.homeLookAt.Y, user.homeLookAt.Z, user.created, user.lastLogin, user.userInventoryURI, user.userAssetURI, user.profileCanDoMask, user.profileWantDoMask, 211 user.homeRegion, user.homeLocation.X, user.homeLocation.Y,
210 user.profileAboutText, user.profileFirstText, user.profileImage, user.profileFirstImage); 212 user.homeLocation.Z,
211 } 213 user.homeLookAt.X, user.homeLookAt.Y, user.homeLookAt.Z, user.created,
212 } 214 user.lastLogin, user.userInventoryURI, user.userAssetURI,
213 catch (Exception e) 215 user.profileCanDoMask, user.profileWantDoMask,
214 { 216 user.profileAboutText, user.profileFirstText, user.profileImage,
215 database.Reconnect(); 217 user.profileFirstImage);
216 MainLog.Instance.Error(e.ToString()); 218 }
217 } 219 }
218 220 catch (Exception e)
221 {
222 database.Reconnect();
223 MainLog.Instance.Error(e.ToString());
224 }
219 } 225 }
220 226
221 /// <summary> 227 /// <summary>
@@ -226,8 +232,8 @@ namespace OpenSim.Framework.Data.MySQL
226 { 232 {
227 // Do nothing. 233 // Do nothing.
228 } 234 }
229 235
230 236
231 public bool UpdateUserProfile(UserProfileData user) 237 public bool UpdateUserProfile(UserProfileData user)
232 { 238 {
233 return true; 239 return true;
@@ -277,4 +283,4 @@ namespace OpenSim.Framework.Data.MySQL
277 return "0.1"; 283 return "0.1";
278 } 284 }
279 } 285 }
280} 286} \ No newline at end of file
diff --git a/OpenSim/Framework/Data.MySQL/Properties/AssemblyInfo.cs b/OpenSim/Framework/Data.MySQL/Properties/AssemblyInfo.cs
index 46c0ae0..7024bfa 100644
--- a/OpenSim/Framework/Data.MySQL/Properties/AssemblyInfo.cs
+++ b/OpenSim/Framework/Data.MySQL/Properties/AssemblyInfo.cs
@@ -1,24 +1,28 @@
1using System.Reflection; 1using System.Reflection;
2using System.Runtime.InteropServices; 2using System.Runtime.InteropServices;
3
3// General Information about an assembly is controlled through the following 4// General Information about an assembly is controlled through the following
4// set of attributes. Change these attribute values to modify the information 5// set of attributes. Change these attribute values to modify the information
5// associated with an assembly. 6// associated with an assembly.
6[assembly: AssemblyTitle("OpenSim.Framework.Data.MySQL")] 7
7[assembly: AssemblyDescription("")] 8[assembly : AssemblyTitle("OpenSim.Framework.Data.MySQL")]
8[assembly: AssemblyConfiguration("")] 9[assembly : AssemblyDescription("")]
9[assembly: AssemblyCompany("")] 10[assembly : AssemblyConfiguration("")]
10[assembly: AssemblyProduct("OpenSim.Framework.Data.MySQL")] 11[assembly : AssemblyCompany("")]
11[assembly: AssemblyCopyright("Copyright © 2007")] 12[assembly : AssemblyProduct("OpenSim.Framework.Data.MySQL")]
12[assembly: AssemblyTrademark("")] 13[assembly : AssemblyCopyright("Copyright © 2007")]
13[assembly: AssemblyCulture("")] 14[assembly : AssemblyTrademark("")]
15[assembly : AssemblyCulture("")]
14 16
15// Setting ComVisible to false makes the types in this assembly not visible 17// Setting ComVisible to false makes the types in this assembly not visible
16// to COM components. If you need to access a type in this assembly from 18// to COM components. If you need to access a type in this assembly from
17// COM, set the ComVisible attribute to true on that type. 19// COM, set the ComVisible attribute to true on that type.
18[assembly: ComVisible(false)] 20
21[assembly : ComVisible(false)]
19 22
20// The following GUID is for the ID of the typelib if this project is exposed to COM 23// The following GUID is for the ID of the typelib if this project is exposed to COM
21[assembly: Guid("e49826b2-dcef-41be-a5bd-596733fa3304")] 24
25[assembly : Guid("e49826b2-dcef-41be-a5bd-596733fa3304")]
22 26
23// Version information for an assembly consists of the following four values: 27// Version information for an assembly consists of the following four values:
24// 28//
@@ -29,5 +33,6 @@ using System.Runtime.InteropServices;
29// 33//
30// You can specify all the values or you can default the Revision and Build Numbers 34// You can specify all the values or you can default the Revision and Build Numbers
31// by using the '*' as shown below: 35// by using the '*' as shown below:
32[assembly: AssemblyVersion("1.0.0.0")] 36
33[assembly: AssemblyFileVersion("1.0.0.0")] 37[assembly : AssemblyVersion("1.0.0.0")]
38[assembly : AssemblyFileVersion("1.0.0.0")] \ No newline at end of file
diff --git a/OpenSim/Framework/Data.SQLite/Properties/AssemblyInfo.cs b/OpenSim/Framework/Data.SQLite/Properties/AssemblyInfo.cs
index 75bb53d..6693c98 100644
--- a/OpenSim/Framework/Data.SQLite/Properties/AssemblyInfo.cs
+++ b/OpenSim/Framework/Data.SQLite/Properties/AssemblyInfo.cs
@@ -1,24 +1,28 @@
1using System.Reflection; 1using System.Reflection;
2using System.Runtime.InteropServices; 2using System.Runtime.InteropServices;
3
3// General Information about an assembly is controlled through the following 4// General Information about an assembly is controlled through the following
4// set of attributes. Change these attribute values to modify the information 5// set of attributes. Change these attribute values to modify the information
5// associated with an assembly. 6// associated with an assembly.
6[assembly: AssemblyTitle("OpenSim.Framework.Data.SQLite")] 7
7[assembly: AssemblyDescription("")] 8[assembly : AssemblyTitle("OpenSim.Framework.Data.SQLite")]
8[assembly: AssemblyConfiguration("")] 9[assembly : AssemblyDescription("")]
9[assembly: AssemblyCompany("")] 10[assembly : AssemblyConfiguration("")]
10[assembly: AssemblyProduct("OpenSim.Framework.Data.SQLite")] 11[assembly : AssemblyCompany("")]
11[assembly: AssemblyCopyright("Copyright © 2007")] 12[assembly : AssemblyProduct("OpenSim.Framework.Data.SQLite")]
12[assembly: AssemblyTrademark("")] 13[assembly : AssemblyCopyright("Copyright © 2007")]
13[assembly: AssemblyCulture("")] 14[assembly : AssemblyTrademark("")]
15[assembly : AssemblyCulture("")]
14 16
15// Setting ComVisible to false makes the types in this assembly not visible 17// Setting ComVisible to false makes the types in this assembly not visible
16// to COM components. If you need to access a type in this assembly from 18// to COM components. If you need to access a type in this assembly from
17// COM, set the ComVisible attribute to true on that type. 19// COM, set the ComVisible attribute to true on that type.
18[assembly: ComVisible(false)] 20
21[assembly : ComVisible(false)]
19 22
20// The following GUID is for the ID of the typelib if this project is exposed to COM 23// The following GUID is for the ID of the typelib if this project is exposed to COM
21[assembly: Guid("6113d5ce-4547-49f4-9236-0dcc503457b1")] 24
25[assembly : Guid("6113d5ce-4547-49f4-9236-0dcc503457b1")]
22 26
23// Version information for an assembly consists of the following four values: 27// Version information for an assembly consists of the following four values:
24// 28//
@@ -29,5 +33,6 @@ using System.Runtime.InteropServices;
29// 33//
30// You can specify all the values or you can default the Revision and Build Numbers 34// You can specify all the values or you can default the Revision and Build Numbers
31// by using the '*' as shown below: 35// by using the '*' as shown below:
32[assembly: AssemblyVersion("0.4.0.0")] 36
33[assembly: AssemblyFileVersion("1.0.0.0")] 37[assembly : AssemblyVersion("0.4.0.0")]
38[assembly : AssemblyFileVersion("1.0.0.0")] \ No newline at end of file
diff --git a/OpenSim/Framework/Data.SQLite/SQLiteAssetData.cs b/OpenSim/Framework/Data.SQLite/SQLiteAssetData.cs
index a85ab4d..4187078 100644
--- a/OpenSim/Framework/Data.SQLite/SQLiteAssetData.cs
+++ b/OpenSim/Framework/Data.SQLite/SQLiteAssetData.cs
@@ -26,15 +26,11 @@
26* 26*
27*/ 27*/
28using System; 28using System;
29using System.IO;
30using libsecondlife;
31using OpenSim.Framework;
32using System.Data; 29using System.Data;
33using System.Data.SqlTypes; 30using System.Reflection;
31using libsecondlife;
34using Mono.Data.SqliteClient; 32using Mono.Data.SqliteClient;
35using OpenSim.Framework.Console; 33using OpenSim.Framework.Console;
36using OpenSim.Framework;
37using OpenSim.Framework.Interfaces;
38 34
39namespace OpenSim.Framework.Data.SQLite 35namespace OpenSim.Framework.Data.SQLite
40{ 36{
@@ -46,11 +42,11 @@ namespace OpenSim.Framework.Data.SQLite
46 /// <summary> 42 /// <summary>
47 /// The database manager 43 /// The database manager
48 /// </summary> 44 /// </summary>
49
50 /// <summary> 45 /// <summary>
51 /// Artificial constructor called upon plugin load 46 /// Artificial constructor called upon plugin load
52 /// </summary> 47 /// </summary>
53 private const string assetSelect = "select * from assets"; 48 private const string assetSelect = "select * from assets";
49
54 private DataSet ds; 50 private DataSet ds;
55 private SqliteDataAdapter da; 51 private SqliteDataAdapter da;
56 52
@@ -58,13 +54,14 @@ namespace OpenSim.Framework.Data.SQLite
58 { 54 {
59 SqliteConnection conn = new SqliteConnection("URI=file:" + dbfile + ",version=3"); 55 SqliteConnection conn = new SqliteConnection("URI=file:" + dbfile + ",version=3");
60 TestTables(conn); 56 TestTables(conn);
61 57
62 ds = new DataSet(); 58 ds = new DataSet();
63 da = new SqliteDataAdapter(new SqliteCommand(assetSelect, conn)); 59 da = new SqliteDataAdapter(new SqliteCommand(assetSelect, conn));
64 60
65 lock (ds) { 61 lock (ds)
62 {
66 ds.Tables.Add(createAssetsTable()); 63 ds.Tables.Add(createAssetsTable());
67 64
68 setupAssetCommands(da, conn); 65 setupAssetCommands(da, conn);
69 try 66 try
70 { 67 {
@@ -75,11 +72,11 @@ namespace OpenSim.Framework.Data.SQLite
75 MainLog.Instance.Verbose("AssetStorage", "Caught fill error on asset table"); 72 MainLog.Instance.Verbose("AssetStorage", "Caught fill error on asset table");
76 } 73 }
77 } 74 }
78 75
79 return; 76 return;
80 } 77 }
81 78
82 public AssetBase FetchAsset(LLUUID uuid) 79 public AssetBase FetchAsset(LLUUID uuid)
83 { 80 {
84 AssetBase asset = new AssetBase(); 81 AssetBase asset = new AssetBase();
85 DataRow row = ds.Tables["assets"].Rows.Find(uuid); 82 DataRow row = ds.Tables["assets"].Rows.Find(uuid);
@@ -92,27 +89,28 @@ namespace OpenSim.Framework.Data.SQLite
92 return null; 89 return null;
93 } 90 }
94 } 91 }
95 92
96 public void CreateAsset(AssetBase asset) 93 public void CreateAsset(AssetBase asset)
97 { 94 {
98 // no difference for now 95 // no difference for now
99 UpdateAsset(asset); 96 UpdateAsset(asset);
100 } 97 }
101 98
102 public void UpdateAsset(AssetBase asset) 99 public void UpdateAsset(AssetBase asset)
103 { 100 {
104 LogAssetLoad(asset); 101 LogAssetLoad(asset);
105 102
106 DataTable assets = ds.Tables["assets"]; 103 DataTable assets = ds.Tables["assets"];
107 lock(ds) { 104 lock (ds)
105 {
108 DataRow row = assets.Rows.Find(asset.FullID); 106 DataRow row = assets.Rows.Find(asset.FullID);
109 if (row == null) 107 if (row == null)
110 { 108 {
111 row = assets.NewRow(); 109 row = assets.NewRow();
112 fillAssetRow(row, asset); 110 fillAssetRow(row, asset);
113 assets.Rows.Add(row); 111 assets.Rows.Add(row);
114 } 112 }
115 else 113 else
116 { 114 {
117 fillAssetRow(row, asset); 115 fillAssetRow(row, asset);
118 } 116 }
@@ -124,9 +122,10 @@ namespace OpenSim.Framework.Data.SQLite
124 string temporary = asset.Temporary ? "Temporary" : "Stored"; 122 string temporary = asset.Temporary ? "Temporary" : "Stored";
125 string local = asset.Local ? "Local" : "Remote"; 123 string local = asset.Local ? "Local" : "Remote";
126 124
127 MainLog.Instance.Verbose("ASSETSTORAGE", 125 MainLog.Instance.Verbose("ASSETSTORAGE",
128 string.Format("Loaded {6} {5} Asset: [{0}][{3}/{4}] \"{1}\":{2} ({7} bytes)", 126 string.Format("Loaded {6} {5} Asset: [{0}][{3}/{4}] \"{1}\":{2} ({7} bytes)",
129 asset.FullID, asset.Name, asset.Description, asset.Type, asset.InvType, temporary, local, asset.Data.Length) ); 127 asset.FullID, asset.Name, asset.Description, asset.Type,
128 asset.InvType, temporary, local, asset.Data.Length));
130 } 129 }
131 130
132 public bool ExistsAsset(LLUUID uuid) 131 public bool ExistsAsset(LLUUID uuid)
@@ -137,23 +136,26 @@ namespace OpenSim.Framework.Data.SQLite
137 136
138 public void DeleteAsset(LLUUID uuid) 137 public void DeleteAsset(LLUUID uuid)
139 { 138 {
140 lock (ds) { 139 lock (ds)
140 {
141 DataRow row = ds.Tables["assets"].Rows.Find(uuid); 141 DataRow row = ds.Tables["assets"].Rows.Find(uuid);
142 if (row != null) { 142 if (row != null)
143 {
143 row.Delete(); 144 row.Delete();
144 } 145 }
145 } 146 }
146 } 147 }
147 148
148 public void CommitAssets() // force a sync to the database 149 public void CommitAssets() // force a sync to the database
149 { 150 {
150 MainLog.Instance.Verbose("AssetStorage", "Attempting commit"); 151 MainLog.Instance.Verbose("AssetStorage", "Attempting commit");
151 lock (ds) { 152 lock (ds)
153 {
152 da.Update(ds, "assets"); 154 da.Update(ds, "assets");
153 ds.AcceptChanges(); 155 ds.AcceptChanges();
154 } 156 }
155 } 157 }
156 158
157 /*********************************************************************** 159 /***********************************************************************
158 * 160 *
159 * Database Definition Functions 161 * Database Definition Functions
@@ -161,24 +163,24 @@ namespace OpenSim.Framework.Data.SQLite
161 * This should be db agnostic as we define them in ADO.NET terms 163 * This should be db agnostic as we define them in ADO.NET terms
162 * 164 *
163 **********************************************************************/ 165 **********************************************************************/
164 166
165 private DataTable createAssetsTable() 167 private DataTable createAssetsTable()
166 { 168 {
167 DataTable assets = new DataTable("assets"); 169 DataTable assets = new DataTable("assets");
168 170
169 createCol(assets, "UUID", typeof(System.String)); 171 createCol(assets, "UUID", typeof (String));
170 createCol(assets, "Name", typeof(System.String)); 172 createCol(assets, "Name", typeof (String));
171 createCol(assets, "Description", typeof(System.String)); 173 createCol(assets, "Description", typeof (String));
172 createCol(assets, "Type", typeof(System.Int32)); 174 createCol(assets, "Type", typeof (Int32));
173 createCol(assets, "InvType", typeof(System.Int32)); 175 createCol(assets, "InvType", typeof (Int32));
174 createCol(assets, "Local", typeof(System.Boolean)); 176 createCol(assets, "Local", typeof (Boolean));
175 createCol(assets, "Temporary", typeof(System.Boolean)); 177 createCol(assets, "Temporary", typeof (Boolean));
176 createCol(assets, "Data", typeof(System.Byte[])); 178 createCol(assets, "Data", typeof (Byte[]));
177 // Add in contraints 179 // Add in contraints
178 assets.PrimaryKey = new DataColumn[] { assets.Columns["UUID"] }; 180 assets.PrimaryKey = new DataColumn[] {assets.Columns["UUID"]};
179 return assets; 181 return assets;
180 } 182 }
181 183
182 /*********************************************************************** 184 /***********************************************************************
183 * 185 *
184 * Convert between ADO.NET <=> OpenSim Objects 186 * Convert between ADO.NET <=> OpenSim Objects
@@ -193,19 +195,19 @@ namespace OpenSim.Framework.Data.SQLite
193 // interesting has to be done to actually get these values 195 // interesting has to be done to actually get these values
194 // back out. Not enough time to figure it out yet. 196 // back out. Not enough time to figure it out yet.
195 AssetBase asset = new AssetBase(); 197 AssetBase asset = new AssetBase();
196 198
197 asset.FullID = new LLUUID((String)row["UUID"]); 199 asset.FullID = new LLUUID((String) row["UUID"]);
198 asset.Name = (String)row["Name"]; 200 asset.Name = (String) row["Name"];
199 asset.Description = (String)row["Description"]; 201 asset.Description = (String) row["Description"];
200 asset.Type = Convert.ToSByte(row["Type"]); 202 asset.Type = Convert.ToSByte(row["Type"]);
201 asset.InvType = Convert.ToSByte(row["InvType"]); 203 asset.InvType = Convert.ToSByte(row["InvType"]);
202 asset.Local = Convert.ToBoolean(row["Local"]); 204 asset.Local = Convert.ToBoolean(row["Local"]);
203 asset.Temporary = Convert.ToBoolean(row["Temporary"]); 205 asset.Temporary = Convert.ToBoolean(row["Temporary"]);
204 asset.Data = (byte[])row["Data"]; 206 asset.Data = (byte[]) row["Data"];
205 return asset; 207 return asset;
206 } 208 }
207 209
208 210
209 private void fillAssetRow(DataRow row, AssetBase asset) 211 private void fillAssetRow(DataRow row, AssetBase asset)
210 { 212 {
211 row["UUID"] = asset.FullID; 213 row["UUID"] = asset.FullID;
@@ -225,8 +227,10 @@ namespace OpenSim.Framework.Data.SQLite
225 row["Data"] = asset.Data; 227 row["Data"] = asset.Data;
226 228
227 // ADO.NET doesn't handle NULL very well 229 // ADO.NET doesn't handle NULL very well
228 foreach (DataColumn col in ds.Tables["assets"].Columns) { 230 foreach (DataColumn col in ds.Tables["assets"].Columns)
229 if (row[col] == null) { 231 {
232 if (row[col] == null)
233 {
230 row[col] = ""; 234 row[col] = "";
231 } 235 }
232 } 236 }
@@ -250,18 +254,18 @@ namespace OpenSim.Framework.Data.SQLite
250 da.UpdateCommand.Connection = conn; 254 da.UpdateCommand.Connection = conn;
251 255
252 SqliteCommand delete = new SqliteCommand("delete from assets where UUID = :UUID"); 256 SqliteCommand delete = new SqliteCommand("delete from assets where UUID = :UUID");
253 delete.Parameters.Add(createSqliteParameter("UUID", typeof(System.String))); 257 delete.Parameters.Add(createSqliteParameter("UUID", typeof (String)));
254 delete.Connection = conn; 258 delete.Connection = conn;
255 da.DeleteCommand = delete; 259 da.DeleteCommand = delete;
256 } 260 }
257 261
258 private void InitDB(SqliteConnection conn) 262 private void InitDB(SqliteConnection conn)
259 { 263 {
260 string createAssets = defineTable(createAssetsTable()); 264 string createAssets = defineTable(createAssetsTable());
261 SqliteCommand pcmd = new SqliteCommand(createAssets, conn); 265 SqliteCommand pcmd = new SqliteCommand(createAssets, conn);
262 conn.Open(); 266 conn.Open();
263 pcmd.ExecuteNonQuery(); 267 pcmd.ExecuteNonQuery();
264 conn.Close(); 268 conn.Close();
265 } 269 }
266 270
267 private bool TestTables(SqliteConnection conn) 271 private bool TestTables(SqliteConnection conn)
@@ -269,9 +273,12 @@ namespace OpenSim.Framework.Data.SQLite
269 SqliteCommand cmd = new SqliteCommand(assetSelect, conn); 273 SqliteCommand cmd = new SqliteCommand(assetSelect, conn);
270 SqliteDataAdapter pDa = new SqliteDataAdapter(cmd); 274 SqliteDataAdapter pDa = new SqliteDataAdapter(cmd);
271 DataSet tmpDS = new DataSet(); 275 DataSet tmpDS = new DataSet();
272 try { 276 try
277 {
273 pDa.Fill(tmpDS, "assets"); 278 pDa.Fill(tmpDS, "assets");
274 } catch (Mono.Data.SqliteClient.SqliteSyntaxException) { 279 }
280 catch (SqliteSyntaxException)
281 {
275 MainLog.Instance.Verbose("DATASTORE", "SQLite Database doesn't exist... creating"); 282 MainLog.Instance.Verbose("DATASTORE", "SQLite Database doesn't exist... creating");
276 InitDB(conn); 283 InitDB(conn);
277 } 284 }
@@ -279,14 +286,18 @@ namespace OpenSim.Framework.Data.SQLite
279 } 286 }
280 287
281 #region IPlugin interface 288 #region IPlugin interface
282 public string Version { 289
290 public string Version
291 {
283 get 292 get
284 { 293 {
285 System.Reflection.Module module = this.GetType().Module; 294 Module module = GetType().Module;
286 string dllName = module.Assembly.ManifestModule.Name; 295 string dllName = module.Assembly.ManifestModule.Name;
287 Version dllVersion = module.Assembly.GetName().Version; 296 Version dllVersion = module.Assembly.GetName().Version;
288 297
289 return string.Format("{0}.{1}.{2}.{3}", dllVersion.Major, dllVersion.Minor, dllVersion.Build, dllVersion.Revision); 298 return
299 string.Format("{0}.{1}.{2}.{3}", dllVersion.Major, dllVersion.Minor, dllVersion.Build,
300 dllVersion.Revision);
290 } 301 }
291 } 302 }
292 303
@@ -295,9 +306,11 @@ namespace OpenSim.Framework.Data.SQLite
295 Initialise("AssetStorage.db", ""); 306 Initialise("AssetStorage.db", "");
296 } 307 }
297 308
298 public string Name { 309 public string Name
310 {
299 get { return "SQLite Asset storage engine"; } 311 get { return "SQLite Asset storage engine"; }
300 } 312 }
313
301 #endregion 314 #endregion
302 } 315 }
303} 316} \ No newline at end of file
diff --git a/OpenSim/Framework/Data.SQLite/SQLiteBase.cs b/OpenSim/Framework/Data.SQLite/SQLiteBase.cs
index 4f237fd..157b4e6 100644
--- a/OpenSim/Framework/Data.SQLite/SQLiteBase.cs
+++ b/OpenSim/Framework/Data.SQLite/SQLiteBase.cs
@@ -26,13 +26,8 @@
26* 26*
27*/ 27*/
28using System; 28using System;
29using System.IO;
30using libsecondlife;
31using OpenSim.Framework;
32using System.Data; 29using System.Data;
33using System.Data.SqlTypes;
34using Mono.Data.SqliteClient; 30using Mono.Data.SqliteClient;
35using OpenSim.Framework.Console;
36 31
37namespace OpenSim.Framework.Data.SQLite 32namespace OpenSim.Framework.Data.SQLite
38{ 33{
@@ -48,8 +43,8 @@ namespace OpenSim.Framework.Data.SQLite
48 * This should be db agnostic as we define them in ADO.NET terms 43 * This should be db agnostic as we define them in ADO.NET terms
49 * 44 *
50 **********************************************************************/ 45 **********************************************************************/
51 46
52 protected static void createCol(DataTable dt, string name, System.Type type) 47 protected static void createCol(DataTable dt, string name, Type type)
53 { 48 {
54 DataColumn col = new DataColumn(name, type); 49 DataColumn col = new DataColumn(name, type);
55 dt.Columns.Add(col); 50 dt.Columns.Add(col);
@@ -77,7 +72,8 @@ namespace OpenSim.Framework.Data.SQLite
77 * generate these strings instead of typing them out. 72 * generate these strings instead of typing them out.
78 */ 73 */
79 string[] cols = new string[dt.Columns.Count]; 74 string[] cols = new string[dt.Columns.Count];
80 for (int i = 0; i < dt.Columns.Count; i++) { 75 for (int i = 0; i < dt.Columns.Count; i++)
76 {
81 DataColumn col = dt.Columns[i]; 77 DataColumn col = dt.Columns[i];
82 cols[i] = col.ColumnName; 78 cols[i] = col.ColumnName;
83 } 79 }
@@ -92,7 +88,7 @@ namespace OpenSim.Framework.Data.SQLite
92 88
93 // this provides the binding for all our parameters, so 89 // this provides the binding for all our parameters, so
94 // much less code than it used to be 90 // much less code than it used to be
95 foreach (DataColumn col in dt.Columns) 91 foreach (DataColumn col in dt.Columns)
96 { 92 {
97 cmd.Parameters.Add(createSqliteParameter(col.ColumnName, col.DataType)); 93 cmd.Parameters.Add(createSqliteParameter(col.ColumnName, col.DataType));
98 } 94 }
@@ -106,7 +102,8 @@ namespace OpenSim.Framework.Data.SQLite
106 foreach (DataColumn col in dt.Columns) 102 foreach (DataColumn col in dt.Columns)
107 { 103 {
108 if (subsql.Length > 0) 104 if (subsql.Length > 0)
109 { // a map function would rock so much here 105 {
106 // a map function would rock so much here
110 subsql += ", "; 107 subsql += ", ";
111 } 108 }
112 subsql += col.ColumnName + "= :" + col.ColumnName; 109 subsql += col.ColumnName + "= :" + col.ColumnName;
@@ -118,7 +115,7 @@ namespace OpenSim.Framework.Data.SQLite
118 // this provides the binding for all our parameters, so 115 // this provides the binding for all our parameters, so
119 // much less code than it used to be 116 // much less code than it used to be
120 117
121 foreach (DataColumn col in dt.Columns) 118 foreach (DataColumn col in dt.Columns)
122 { 119 {
123 cmd.Parameters.Add(createSqliteParameter(col.ColumnName, col.DataType)); 120 cmd.Parameters.Add(createSqliteParameter(col.ColumnName, col.DataType));
124 } 121 }
@@ -133,11 +130,12 @@ namespace OpenSim.Framework.Data.SQLite
133 foreach (DataColumn col in dt.Columns) 130 foreach (DataColumn col in dt.Columns)
134 { 131 {
135 if (subsql.Length > 0) 132 if (subsql.Length > 0)
136 { // a map function would rock so much here 133 {
134 // a map function would rock so much here
137 subsql += ",\n"; 135 subsql += ",\n";
138 } 136 }
139 subsql += col.ColumnName + " " + sqliteType(col.DataType); 137 subsql += col.ColumnName + " " + sqliteType(col.DataType);
140 if(col == dt.PrimaryKey[0]) 138 if (col == dt.PrimaryKey[0])
141 { 139 {
142 subsql += " primary key"; 140 subsql += " primary key";
143 } 141 }
@@ -167,7 +165,7 @@ namespace OpenSim.Framework.Data.SQLite
167 /// for us. 165 /// for us.
168 ///</summary> 166 ///</summary>
169 ///<returns>a built sqlite parameter</returns> 167 ///<returns>a built sqlite parameter</returns>
170 protected static SqliteParameter createSqliteParameter(string name, System.Type type) 168 protected static SqliteParameter createSqliteParameter(string name, Type type)
171 { 169 {
172 SqliteParameter param = new SqliteParameter(); 170 SqliteParameter param = new SqliteParameter();
173 param.ParameterName = ":" + name; 171 param.ParameterName = ":" + name;
@@ -182,53 +180,87 @@ namespace OpenSim.Framework.Data.SQLite
182 * Type conversion functions 180 * Type conversion functions
183 * 181 *
184 **********************************************************************/ 182 **********************************************************************/
185 183
186 protected static DbType dbtypeFromType(Type type) 184 protected static DbType dbtypeFromType(Type type)
187 { 185 {
188 if (type == typeof(System.String)) { 186 if (type == typeof (String))
187 {
189 return DbType.String; 188 return DbType.String;
190 } else if (type == typeof(System.Int32)) { 189 }
190 else if (type == typeof (Int32))
191 {
191 return DbType.Int32; 192 return DbType.Int32;
192 } else if (type == typeof(System.UInt32)) { 193 }
194 else if (type == typeof (UInt32))
195 {
193 return DbType.UInt32; 196 return DbType.UInt32;
194 } else if (type == typeof(System.Int64)) { 197 }
198 else if (type == typeof (Int64))
199 {
195 return DbType.Int64; 200 return DbType.Int64;
196 } else if (type == typeof(System.UInt64)) { 201 }
202 else if (type == typeof (UInt64))
203 {
197 return DbType.UInt64; 204 return DbType.UInt64;
198 } else if (type == typeof(System.Double)) { 205 }
206 else if (type == typeof (Double))
207 {
199 return DbType.Double; 208 return DbType.Double;
200 } else if (type == typeof(System.Boolean)) { 209 }
210 else if (type == typeof (Boolean))
211 {
201 return DbType.Boolean; 212 return DbType.Boolean;
202 } else if (type == typeof(System.Byte[])) { 213 }
214 else if (type == typeof (Byte[]))
215 {
203 return DbType.Binary; 216 return DbType.Binary;
204 } else { 217 }
218 else
219 {
205 return DbType.String; 220 return DbType.String;
206 } 221 }
207 } 222 }
208 223
209 // this is something we'll need to implement for each db 224 // this is something we'll need to implement for each db
210 // slightly differently. 225 // slightly differently.
211 protected static string sqliteType(Type type) 226 protected static string sqliteType(Type type)
212 { 227 {
213 if (type == typeof(System.String)) { 228 if (type == typeof (String))
229 {
214 return "varchar(255)"; 230 return "varchar(255)";
215 } else if (type == typeof(System.Int32)) { 231 }
232 else if (type == typeof (Int32))
233 {
216 return "integer"; 234 return "integer";
217 } else if (type == typeof(System.UInt32)) { 235 }
236 else if (type == typeof (UInt32))
237 {
218 return "integer"; 238 return "integer";
219 } else if (type == typeof(System.Int64)) { 239 }
240 else if (type == typeof (Int64))
241 {
220 return "varchar(255)"; 242 return "varchar(255)";
221 } else if (type == typeof(System.UInt64)) { 243 }
244 else if (type == typeof (UInt64))
245 {
222 return "varchar(255)"; 246 return "varchar(255)";
223 } else if (type == typeof(System.Double)) { 247 }
248 else if (type == typeof (Double))
249 {
224 return "float"; 250 return "float";
225 } else if (type == typeof(System.Boolean)) { 251 }
252 else if (type == typeof (Boolean))
253 {
226 return "integer"; 254 return "integer";
227 } else if (type == typeof(System.Byte[])) { 255 }
256 else if (type == typeof (Byte[]))
257 {
228 return "blob"; 258 return "blob";
229 } else { 259 }
260 else
261 {
230 return "string"; 262 return "string";
231 } 263 }
232 } 264 }
233 } 265 }
234} 266} \ No newline at end of file
diff --git a/OpenSim/Framework/Data.SQLite/SQLiteGridData.cs b/OpenSim/Framework/Data.SQLite/SQLiteGridData.cs
index 2fc80b4..8f3e8aa 100644
--- a/OpenSim/Framework/Data.SQLite/SQLiteGridData.cs
+++ b/OpenSim/Framework/Data.SQLite/SQLiteGridData.cs
@@ -192,4 +192,4 @@ namespace OpenSim.Framework.Data.SQLite
192 return null; 192 return null;
193 } 193 }
194 } 194 }
195} 195} \ No newline at end of file
diff --git a/OpenSim/Framework/Data.SQLite/SQLiteInventoryStore.cs b/OpenSim/Framework/Data.SQLite/SQLiteInventoryStore.cs
index 82a8434..5e95878 100644
--- a/OpenSim/Framework/Data.SQLite/SQLiteInventoryStore.cs
+++ b/OpenSim/Framework/Data.SQLite/SQLiteInventoryStore.cs
@@ -28,22 +28,14 @@
28 28
29using System; 29using System;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Text; 31using System.Data;
32using System.Reflection; 32using System.Reflection;
33
34using OpenSim.Framework.Console;
35using OpenSim.Framework;
36using OpenSim.Framework;
37using libsecondlife; 33using libsecondlife;
38
39using System.Data;
40using System.Data.SqlTypes;
41
42using Mono.Data.SqliteClient; 34using Mono.Data.SqliteClient;
35using OpenSim.Framework.Console;
43 36
44namespace OpenSim.Framework.Data.SQLite 37namespace OpenSim.Framework.Data.SQLite
45{ 38{
46
47 public class SQLiteInventoryStore : SQLiteBase, IInventoryData 39 public class SQLiteInventoryStore : SQLiteBase, IInventoryData
48 { 40 {
49 private const string invItemsSelect = "select * from inventoryitems"; 41 private const string invItemsSelect = "select * from inventoryitems";
@@ -96,14 +88,14 @@ namespace OpenSim.Framework.Data.SQLite
96 public InventoryItemBase buildItem(DataRow row) 88 public InventoryItemBase buildItem(DataRow row)
97 { 89 {
98 InventoryItemBase item = new InventoryItemBase(); 90 InventoryItemBase item = new InventoryItemBase();
99 item.inventoryID = new LLUUID((string)row["UUID"]); 91 item.inventoryID = new LLUUID((string) row["UUID"]);
100 item.assetID = new LLUUID((string)row["assetID"]); 92 item.assetID = new LLUUID((string) row["assetID"]);
101 item.assetType = Convert.ToInt32(row["assetType"]); 93 item.assetType = Convert.ToInt32(row["assetType"]);
102 item.invType = Convert.ToInt32(row["invType"]); 94 item.invType = Convert.ToInt32(row["invType"]);
103 item.parentFolderID = new LLUUID((string)row["parentFolderID"]); 95 item.parentFolderID = new LLUUID((string) row["parentFolderID"]);
104 item.avatarID = new LLUUID((string)row["avatarID"]); 96 item.avatarID = new LLUUID((string) row["avatarID"]);
105 item.creatorsID = new LLUUID((string)row["creatorsID"]); 97 item.creatorsID = new LLUUID((string) row["creatorsID"]);
106 item.inventoryName =(string) row["inventoryName"]; 98 item.inventoryName = (string) row["inventoryName"];
107 item.inventoryDescription = (string) row["inventoryDescription"]; 99 item.inventoryDescription = (string) row["inventoryDescription"];
108 100
109 item.inventoryNextPermissions = Convert.ToUInt32(row["inventoryNextPermissions"]); 101 item.inventoryNextPermissions = Convert.ToUInt32(row["inventoryNextPermissions"]);
@@ -147,7 +139,7 @@ namespace OpenSim.Framework.Data.SQLite
147 fillFolderRow(inventoryRow, folder); 139 fillFolderRow(inventoryRow, folder);
148 } 140 }
149 141
150 this.invFoldersDa.Update(ds, "inventoryfolders"); 142 invFoldersDa.Update(ds, "inventoryfolders");
151 } 143 }
152 144
153 private void addItem(InventoryItemBase item) 145 private void addItem(InventoryItemBase item)
@@ -165,7 +157,7 @@ namespace OpenSim.Framework.Data.SQLite
165 { 157 {
166 fillItemRow(inventoryRow, item); 158 fillItemRow(inventoryRow, item);
167 } 159 }
168 this.invItemsDa.Update(ds, "inventoryitems"); 160 invItemsDa.Update(ds, "inventoryitems");
169 } 161 }
170 162
171 public void Shutdown() 163 public void Shutdown()
@@ -195,12 +187,14 @@ namespace OpenSim.Framework.Data.SQLite
195 /// <returns>A string containing the plugin version</returns> 187 /// <returns>A string containing the plugin version</returns>
196 public string getVersion() 188 public string getVersion()
197 { 189 {
198 System.Reflection.Module module = this.GetType().Module; 190 Module module = GetType().Module;
199 string dllName = module.Assembly.ManifestModule.Name; 191 string dllName = module.Assembly.ManifestModule.Name;
200 Version dllVersion = module.Assembly.GetName().Version; 192 Version dllVersion = module.Assembly.GetName().Version;
201 193
202 194
203 return string.Format("{0}.{1}.{2}.{3}", dllVersion.Major, dllVersion.Minor, dllVersion.Build, dllVersion.Revision); 195 return
196 string.Format("{0}.{1}.{2}.{3}", dllVersion.Major, dllVersion.Minor, dllVersion.Build,
197 dllVersion.Revision);
204 } 198 }
205 199
206 /// <summary> 200 /// <summary>
@@ -306,7 +300,7 @@ namespace OpenSim.Framework.Data.SQLite
306 List<InventoryFolderBase> folders = new List<InventoryFolderBase>(); 300 List<InventoryFolderBase> folders = new List<InventoryFolderBase>();
307 getInventoryFolders(ref folders, parentID); 301 getInventoryFolders(ref folders, parentID);
308 302
309 for(int i=0; i<folders.Count; i++) 303 for (int i = 0; i < folders.Count; i++)
310 getInventoryFolders(ref folders, folders[i].folderID); 304 getInventoryFolders(ref folders, folders[i].folderID);
311 305
312 return folders; 306 return folders;
@@ -320,9 +314,12 @@ namespace OpenSim.Framework.Data.SQLite
320 public InventoryItemBase getInventoryItem(LLUUID item) 314 public InventoryItemBase getInventoryItem(LLUUID item)
321 { 315 {
322 DataRow row = ds.Tables["inventoryitems"].Rows.Find(item); 316 DataRow row = ds.Tables["inventoryitems"].Rows.Find(item);
323 if (row != null) { 317 if (row != null)
318 {
324 return buildItem(row); 319 return buildItem(row);
325 } else { 320 }
321 else
322 {
326 return null; 323 return null;
327 } 324 }
328 } 325 }
@@ -334,19 +331,21 @@ namespace OpenSim.Framework.Data.SQLite
334 /// <returns>A class containing folder information</returns> 331 /// <returns>A class containing folder information</returns>
335 public InventoryFolderBase getInventoryFolder(LLUUID folder) 332 public InventoryFolderBase getInventoryFolder(LLUUID folder)
336 { 333 {
337 334 // TODO: Deep voodoo here. If you enable this code then
338 // TODO: Deep voodoo here. If you enable this code then 335 // multi region breaks. No idea why, but I figured it was
339 // multi region breaks. No idea why, but I figured it was 336 // better to leave multi region at this point. It does mean
340 // better to leave multi region at this point. It does mean 337 // that you don't get to see system textures why creating
341 // that you don't get to see system textures why creating 338 // clothes and the like. :(
342 // clothes and the like. :( 339
343 340 DataRow row = ds.Tables["inventoryfolders"].Rows.Find(folder);
344 DataRow row = ds.Tables["inventoryfolders"].Rows.Find(folder); 341 if (row != null)
345 if (row != null) { 342 {
346 return buildFolder(row); 343 return buildFolder(row);
347 } else { 344 }
345 else
346 {
348 return null; 347 return null;
349 } 348 }
350 } 349 }
351 350
352 /// <summary> 351 /// <summary>
@@ -355,7 +354,7 @@ namespace OpenSim.Framework.Data.SQLite
355 /// <param name="item">The item to be created</param> 354 /// <param name="item">The item to be created</param>
356 public void addInventoryItem(InventoryItemBase item) 355 public void addInventoryItem(InventoryItemBase item)
357 { 356 {
358 this.addItem(item); 357 addItem(item);
359 } 358 }
360 359
361 /// <summary> 360 /// <summary>
@@ -364,7 +363,7 @@ namespace OpenSim.Framework.Data.SQLite
364 /// <param name="item">The updated item</param> 363 /// <param name="item">The updated item</param>
365 public void updateInventoryItem(InventoryItemBase item) 364 public void updateInventoryItem(InventoryItemBase item)
366 { 365 {
367 this.addItem(item); 366 addItem(item);
368 } 367 }
369 368
370 /// <summary> 369 /// <summary>
@@ -376,12 +375,12 @@ namespace OpenSim.Framework.Data.SQLite
376 DataTable inventoryItemTable = ds.Tables["inventoryitems"]; 375 DataTable inventoryItemTable = ds.Tables["inventoryitems"];
377 376
378 DataRow inventoryRow = inventoryItemTable.Rows.Find(itemID); 377 DataRow inventoryRow = inventoryItemTable.Rows.Find(itemID);
379 if (inventoryRow != null) 378 if (inventoryRow != null)
380 { 379 {
381 inventoryRow.Delete(); 380 inventoryRow.Delete();
382 } 381 }
383 382
384 this.invItemsDa.Update(ds, "inventoryitems"); 383 invItemsDa.Update(ds, "inventoryitems");
385 } 384 }
386 385
387 386
@@ -394,7 +393,7 @@ namespace OpenSim.Framework.Data.SQLite
394 { 393 {
395 List<InventoryItemBase> items = getInventoryInFolder(folderId); 394 List<InventoryItemBase> items = getInventoryInFolder(folderId);
396 395
397 foreach(InventoryItemBase i in items) 396 foreach (InventoryItemBase i in items)
398 deleteInventoryItem(i.inventoryID); 397 deleteInventoryItem(i.inventoryID);
399 } 398 }
400 399
@@ -404,7 +403,7 @@ namespace OpenSim.Framework.Data.SQLite
404 /// <param name="folder">The inventory folder</param> 403 /// <param name="folder">The inventory folder</param>
405 public void addInventoryFolder(InventoryFolderBase folder) 404 public void addInventoryFolder(InventoryFolderBase folder)
406 { 405 {
407 this.addFolder(folder); 406 addFolder(folder);
408 } 407 }
409 408
410 /// <summary> 409 /// <summary>
@@ -413,7 +412,7 @@ namespace OpenSim.Framework.Data.SQLite
413 /// <param name="folder">The inventory folder</param> 412 /// <param name="folder">The inventory folder</param>
414 public void updateInventoryFolder(InventoryFolderBase folder) 413 public void updateInventoryFolder(InventoryFolderBase folder)
415 { 414 {
416 this.addFolder(folder); 415 addFolder(folder);
417 } 416 }
418 417
419 418
@@ -427,7 +426,7 @@ namespace OpenSim.Framework.Data.SQLite
427 public void deleteInventoryFolder(LLUUID folderID) 426 public void deleteInventoryFolder(LLUUID folderID)
428 { 427 {
429 List<InventoryFolderBase> subFolders = getFolderHierarchy(folderID); 428 List<InventoryFolderBase> subFolders = getFolderHierarchy(folderID);
430 429
431 DataTable inventoryFolderTable = ds.Tables["inventoryfolders"]; 430 DataTable inventoryFolderTable = ds.Tables["inventoryfolders"];
432 DataRow inventoryRow; 431 DataRow inventoryRow;
433 432
@@ -450,7 +449,7 @@ namespace OpenSim.Framework.Data.SQLite
450 inventoryRow.Delete(); 449 inventoryRow.Delete();
451 } 450 }
452 451
453 this.invFoldersDa.Update(ds, "inventoryfolders"); 452 invFoldersDa.Update(ds, "inventoryfolders");
454 } 453 }
455 454
456 /*********************************************************************** 455 /***********************************************************************
@@ -458,43 +457,43 @@ namespace OpenSim.Framework.Data.SQLite
458 * Data Table definitions 457 * Data Table definitions
459 * 458 *
460 **********************************************************************/ 459 **********************************************************************/
461 460
462 private static DataTable createInventoryItemsTable() 461 private static DataTable createInventoryItemsTable()
463 { 462 {
464 DataTable inv = new DataTable("inventoryitems"); 463 DataTable inv = new DataTable("inventoryitems");
465 464
466 createCol(inv, "UUID", typeof(System.String)); //inventoryID 465 createCol(inv, "UUID", typeof (String)); //inventoryID
467 createCol(inv, "assetID", typeof(System.String)); 466 createCol(inv, "assetID", typeof (String));
468 createCol(inv, "assetType", typeof(System.Int32)); 467 createCol(inv, "assetType", typeof (Int32));
469 createCol(inv, "invType", typeof(System.Int32)); 468 createCol(inv, "invType", typeof (Int32));
470 createCol(inv, "parentFolderID", typeof(System.String)); 469 createCol(inv, "parentFolderID", typeof (String));
471 createCol(inv, "avatarID", typeof(System.String)); 470 createCol(inv, "avatarID", typeof (String));
472 createCol(inv, "creatorsID", typeof(System.String)); 471 createCol(inv, "creatorsID", typeof (String));
473 472
474 createCol(inv, "inventoryName", typeof(System.String)); 473 createCol(inv, "inventoryName", typeof (String));
475 createCol(inv, "inventoryDescription", typeof(System.String)); 474 createCol(inv, "inventoryDescription", typeof (String));
476 // permissions 475 // permissions
477 createCol(inv, "inventoryNextPermissions", typeof(System.Int32)); 476 createCol(inv, "inventoryNextPermissions", typeof (Int32));
478 createCol(inv, "inventoryCurrentPermissions", typeof(System.Int32)); 477 createCol(inv, "inventoryCurrentPermissions", typeof (Int32));
479 createCol(inv, "inventoryBasePermissions", typeof(System.Int32)); 478 createCol(inv, "inventoryBasePermissions", typeof (Int32));
480 createCol(inv, "inventoryEveryOnePermissions", typeof(System.Int32)); 479 createCol(inv, "inventoryEveryOnePermissions", typeof (Int32));
481 480
482 inv.PrimaryKey = new DataColumn[] { inv.Columns["UUID"] }; 481 inv.PrimaryKey = new DataColumn[] {inv.Columns["UUID"]};
483 return inv; 482 return inv;
484 } 483 }
485 484
486 private DataTable createInventoryFoldersTable() 485 private DataTable createInventoryFoldersTable()
487 { 486 {
488 DataTable fol = new DataTable("inventoryfolders"); 487 DataTable fol = new DataTable("inventoryfolders");
489 488
490 createCol(fol, "UUID", typeof(System.String)); //folderID 489 createCol(fol, "UUID", typeof (String)); //folderID
491 createCol(fol, "name", typeof(System.String)); 490 createCol(fol, "name", typeof (String));
492 createCol(fol, "agentID", typeof(System.String)); 491 createCol(fol, "agentID", typeof (String));
493 createCol(fol, "parentID", typeof(System.String)); 492 createCol(fol, "parentID", typeof (String));
494 createCol(fol, "type", typeof(System.Int32)); 493 createCol(fol, "type", typeof (Int32));
495 createCol(fol, "version", typeof(System.Int32)); 494 createCol(fol, "version", typeof (Int32));
496 495
497 fol.PrimaryKey = new DataColumn[] { fol.Columns["UUID"] }; 496 fol.PrimaryKey = new DataColumn[] {fol.Columns["UUID"]};
498 return fol; 497 return fol;
499 } 498 }
500 499
@@ -507,7 +506,7 @@ namespace OpenSim.Framework.Data.SQLite
507 da.UpdateCommand.Connection = conn; 506 da.UpdateCommand.Connection = conn;
508 507
509 SqliteCommand delete = new SqliteCommand("delete from inventoryitems where UUID = :UUID"); 508 SqliteCommand delete = new SqliteCommand("delete from inventoryitems where UUID = :UUID");
510 delete.Parameters.Add(createSqliteParameter("UUID", typeof(System.String))); 509 delete.Parameters.Add(createSqliteParameter("UUID", typeof (String)));
511 delete.Connection = conn; 510 delete.Connection = conn;
512 da.DeleteCommand = delete; 511 da.DeleteCommand = delete;
513 } 512 }
@@ -521,7 +520,7 @@ namespace OpenSim.Framework.Data.SQLite
521 da.UpdateCommand.Connection = conn; 520 da.UpdateCommand.Connection = conn;
522 521
523 SqliteCommand delete = new SqliteCommand("delete from inventoryfolders where UUID = :UUID"); 522 SqliteCommand delete = new SqliteCommand("delete from inventoryfolders where UUID = :UUID");
524 delete.Parameters.Add(createSqliteParameter("UUID", typeof(System.String))); 523 delete.Parameters.Add(createSqliteParameter("UUID", typeof (String)));
525 delete.Connection = conn; 524 delete.Connection = conn;
526 da.DeleteCommand = delete; 525 da.DeleteCommand = delete;
527 } 526 }
@@ -529,10 +528,10 @@ namespace OpenSim.Framework.Data.SQLite
529 private InventoryFolderBase buildFolder(DataRow row) 528 private InventoryFolderBase buildFolder(DataRow row)
530 { 529 {
531 InventoryFolderBase folder = new InventoryFolderBase(); 530 InventoryFolderBase folder = new InventoryFolderBase();
532 folder.folderID = new LLUUID((string)row["UUID"]); 531 folder.folderID = new LLUUID((string) row["UUID"]);
533 folder.name = (string)row["name"]; 532 folder.name = (string) row["name"];
534 folder.agentID = new LLUUID((string)row["agentID"]); 533 folder.agentID = new LLUUID((string) row["agentID"]);
535 folder.parentID = new LLUUID((string)row["parentID"]); 534 folder.parentID = new LLUUID((string) row["parentID"]);
536 folder.type = Convert.ToInt16(row["type"]); 535 folder.type = Convert.ToInt16(row["type"]);
537 folder.version = Convert.ToUInt16(row["version"]); 536 folder.version = Convert.ToUInt16(row["version"]);
538 return folder; 537 return folder;
@@ -554,17 +553,18 @@ namespace OpenSim.Framework.Data.SQLite
554 * Test and Initialization code 553 * Test and Initialization code
555 * 554 *
556 **********************************************************************/ 555 **********************************************************************/
556
557 private void InitDB(SqliteConnection conn) 557 private void InitDB(SqliteConnection conn)
558 { 558 {
559 string createInventoryItems = defineTable(createInventoryItemsTable()); 559 string createInventoryItems = defineTable(createInventoryItemsTable());
560 string createInventoryFolders = defineTable(createInventoryFoldersTable()); 560 string createInventoryFolders = defineTable(createInventoryFoldersTable());
561 561
562 SqliteCommand pcmd = new SqliteCommand(createInventoryItems, conn); 562 SqliteCommand pcmd = new SqliteCommand(createInventoryItems, conn);
563 SqliteCommand scmd = new SqliteCommand(createInventoryFolders, conn); 563 SqliteCommand scmd = new SqliteCommand(createInventoryFolders, conn);
564 conn.Open(); 564 conn.Open();
565 pcmd.ExecuteNonQuery(); 565 pcmd.ExecuteNonQuery();
566 scmd.ExecuteNonQuery(); 566 scmd.ExecuteNonQuery();
567 conn.Close(); 567 conn.Close();
568 } 568 }
569 569
570 private bool TestTables(SqliteConnection conn) 570 private bool TestTables(SqliteConnection conn)
@@ -575,10 +575,13 @@ namespace OpenSim.Framework.Data.SQLite
575 SqliteDataAdapter sDa = new SqliteDataAdapter(invFoldersSelectCmd); 575 SqliteDataAdapter sDa = new SqliteDataAdapter(invFoldersSelectCmd);
576 576
577 DataSet tmpDS = new DataSet(); 577 DataSet tmpDS = new DataSet();
578 try { 578 try
579 {
579 pDa.Fill(tmpDS, "inventoryitems"); 580 pDa.Fill(tmpDS, "inventoryitems");
580 sDa.Fill(tmpDS, "inventoryfolders"); 581 sDa.Fill(tmpDS, "inventoryfolders");
581 } catch (Mono.Data.SqliteClient.SqliteSyntaxException) { 582 }
583 catch (SqliteSyntaxException)
584 {
582 MainLog.Instance.Verbose("DATASTORE", "SQLite Database doesn't exist... creating"); 585 MainLog.Instance.Verbose("DATASTORE", "SQLite Database doesn't exist... creating");
583 InitDB(conn); 586 InitDB(conn);
584 } 587 }
@@ -586,14 +589,18 @@ namespace OpenSim.Framework.Data.SQLite
586 pDa.Fill(tmpDS, "inventoryitems"); 589 pDa.Fill(tmpDS, "inventoryitems");
587 sDa.Fill(tmpDS, "inventoryfolders"); 590 sDa.Fill(tmpDS, "inventoryfolders");
588 591
589 foreach (DataColumn col in createInventoryItemsTable().Columns) { 592 foreach (DataColumn col in createInventoryItemsTable().Columns)
590 if (! tmpDS.Tables["inventoryitems"].Columns.Contains(col.ColumnName) ) { 593 {
594 if (! tmpDS.Tables["inventoryitems"].Columns.Contains(col.ColumnName))
595 {
591 MainLog.Instance.Verbose("DATASTORE", "Missing required column:" + col.ColumnName); 596 MainLog.Instance.Verbose("DATASTORE", "Missing required column:" + col.ColumnName);
592 return false; 597 return false;
593 } 598 }
594 } 599 }
595 foreach (DataColumn col in createInventoryFoldersTable().Columns) { 600 foreach (DataColumn col in createInventoryFoldersTable().Columns)
596 if (! tmpDS.Tables["inventoryfolders"].Columns.Contains(col.ColumnName) ) { 601 {
602 if (! tmpDS.Tables["inventoryfolders"].Columns.Contains(col.ColumnName))
603 {
597 MainLog.Instance.Verbose("DATASTORE", "Missing required column:" + col.ColumnName); 604 MainLog.Instance.Verbose("DATASTORE", "Missing required column:" + col.ColumnName);
598 return false; 605 return false;
599 } 606 }
@@ -601,8 +608,4 @@ namespace OpenSim.Framework.Data.SQLite
601 return true; 608 return true;
602 } 609 }
603 } 610 }
604} 611} \ No newline at end of file
605
606
607
608
diff --git a/OpenSim/Framework/Data.SQLite/SQLiteManager.cs b/OpenSim/Framework/Data.SQLite/SQLiteManager.cs
index 5954fba..e102da3 100644
--- a/OpenSim/Framework/Data.SQLite/SQLiteManager.cs
+++ b/OpenSim/Framework/Data.SQLite/SQLiteManager.cs
@@ -30,13 +30,14 @@ using System.Collections.Generic;
30using System.Data; 30using System.Data;
31using System.Data.SQLite; 31using System.Data.SQLite;
32using libsecondlife; 32using libsecondlife;
33using Mono.Data.SqliteClient;
33using OpenSim.Framework.Console; 34using OpenSim.Framework.Console;
34 35
35namespace OpenSim.Framework.Data.SQLite 36namespace OpenSim.Framework.Data.SQLite
36{ 37{
37 class SQLiteManager : SQLiteBase 38 internal class SQLiteManager : SQLiteBase
38 { 39 {
39 IDbConnection dbcon; 40 private IDbConnection dbcon;
40 41
41 /// <summary> 42 /// <summary>
42 /// Initialises and creates a new SQLite connection and maintains it. 43 /// Initialises and creates a new SQLite connection and maintains it.
@@ -78,15 +79,15 @@ namespace OpenSim.Framework.Data.SQLite
78 /// <returns>A SQLite DB Command</returns> 79 /// <returns>A SQLite DB Command</returns>
79 public IDbCommand Query(string sql, Dictionary<string, string> parameters) 80 public IDbCommand Query(string sql, Dictionary<string, string> parameters)
80 { 81 {
81 SQLiteCommand dbcommand = (SQLiteCommand)dbcon.CreateCommand(); 82 SQLiteCommand dbcommand = (SQLiteCommand) dbcon.CreateCommand();
82 dbcommand.CommandText = sql; 83 dbcommand.CommandText = sql;
83 foreach (KeyValuePair<string, string> param in parameters) 84 foreach (KeyValuePair<string, string> param in parameters)
84 { 85 {
85 SQLiteParameter paramx = new SQLiteParameter(param.Key,param.Value); 86 SQLiteParameter paramx = new SQLiteParameter(param.Key, param.Value);
86 dbcommand.Parameters.Add(paramx); 87 dbcommand.Parameters.Add(paramx);
87 } 88 }
88 89
89 return (IDbCommand)dbcommand; 90 return (IDbCommand) dbcommand;
90 } 91 }
91 92
92 private bool TestTables(SQLiteConnection conn) 93 private bool TestTables(SQLiteConnection conn)
@@ -98,7 +99,7 @@ namespace OpenSim.Framework.Data.SQLite
98 { 99 {
99 pDa.Fill(tmpDS, "regions"); 100 pDa.Fill(tmpDS, "regions");
100 } 101 }
101 catch (Mono.Data.SqliteClient.SqliteSyntaxException) 102 catch (SqliteSyntaxException)
102 { 103 {
103 MainLog.Instance.Verbose("DATASTORE", "SQLite Database doesn't exist... creating"); 104 MainLog.Instance.Verbose("DATASTORE", "SQLite Database doesn't exist... creating");
104 InitDB(conn); 105 InitDB(conn);
@@ -110,39 +111,39 @@ namespace OpenSim.Framework.Data.SQLite
110 { 111 {
111 DataTable regions = new DataTable("regions"); 112 DataTable regions = new DataTable("regions");
112 113
113 createCol(regions, "regionHandle", typeof(ulong)); 114 createCol(regions, "regionHandle", typeof (ulong));
114 createCol(regions, "regionName", typeof(System.String)); 115 createCol(regions, "regionName", typeof (String));
115 createCol(regions, "uuid", typeof(System.String)); 116 createCol(regions, "uuid", typeof (String));
116 117
117 createCol(regions, "regionRecvKey", typeof(System.String)); 118 createCol(regions, "regionRecvKey", typeof (String));
118 createCol(regions, "regionSecret", typeof(System.String)); 119 createCol(regions, "regionSecret", typeof (String));
119 createCol(regions, "regionSendKey", typeof(System.String)); 120 createCol(regions, "regionSendKey", typeof (String));
120 121
121 createCol(regions, "regionDataURI", typeof(System.String)); 122 createCol(regions, "regionDataURI", typeof (String));
122 createCol(regions, "serverIP", typeof(System.String)); 123 createCol(regions, "serverIP", typeof (String));
123 createCol(regions, "serverPort", typeof(System.String)); 124 createCol(regions, "serverPort", typeof (String));
124 createCol(regions, "serverURI", typeof(System.String)); 125 createCol(regions, "serverURI", typeof (String));
125 126
126 127
127 createCol(regions, "locX", typeof( uint)); 128 createCol(regions, "locX", typeof (uint));
128 createCol(regions, "locY", typeof( uint)); 129 createCol(regions, "locY", typeof (uint));
129 createCol(regions, "locZ", typeof( uint)); 130 createCol(regions, "locZ", typeof (uint));
130 131
131 createCol(regions, "eastOverrideHandle", typeof( ulong )); 132 createCol(regions, "eastOverrideHandle", typeof (ulong));
132 createCol(regions, "westOverrideHandle", typeof( ulong )); 133 createCol(regions, "westOverrideHandle", typeof (ulong));
133 createCol(regions, "southOverrideHandle", typeof( ulong )); 134 createCol(regions, "southOverrideHandle", typeof (ulong));
134 createCol(regions, "northOverrideHandle", typeof( ulong )); 135 createCol(regions, "northOverrideHandle", typeof (ulong));
135 136
136 createCol(regions, "regionAssetURI", typeof(System.String)); 137 createCol(regions, "regionAssetURI", typeof (String));
137 createCol(regions, "regionAssetRecvKey", typeof(System.String)); 138 createCol(regions, "regionAssetRecvKey", typeof (String));
138 createCol(regions, "regionAssetSendKey", typeof(System.String)); 139 createCol(regions, "regionAssetSendKey", typeof (String));
139 140
140 createCol(regions, "regionUserURI", typeof(System.String)); 141 createCol(regions, "regionUserURI", typeof (String));
141 createCol(regions, "regionUserRecvKey", typeof(System.String)); 142 createCol(regions, "regionUserRecvKey", typeof (String));
142 createCol(regions, "regionUserSendKey", typeof(System.String)); 143 createCol(regions, "regionUserSendKey", typeof (String));
143 144
144 // Add in contraints 145 // Add in contraints
145 regions.PrimaryKey = new DataColumn[] { regions.Columns["UUID"] }; 146 regions.PrimaryKey = new DataColumn[] {regions.Columns["UUID"]};
146 return regions; 147 return regions;
147 } 148 }
148 149
@@ -168,42 +169,42 @@ namespace OpenSim.Framework.Data.SQLite
168 if (reader.Read()) 169 if (reader.Read())
169 { 170 {
170 // Region Main 171 // Region Main
171 retval.regionHandle = (ulong)reader["regionHandle"]; 172 retval.regionHandle = (ulong) reader["regionHandle"];
172 retval.regionName = (string)reader["regionName"]; 173 retval.regionName = (string) reader["regionName"];
173 retval.UUID = new LLUUID((string)reader["uuid"]); 174 retval.UUID = new LLUUID((string) reader["uuid"]);
174 175
175 // Secrets 176 // Secrets
176 retval.regionRecvKey = (string)reader["regionRecvKey"]; 177 retval.regionRecvKey = (string) reader["regionRecvKey"];
177 retval.regionSecret = (string)reader["regionSecret"]; 178 retval.regionSecret = (string) reader["regionSecret"];
178 retval.regionSendKey = (string)reader["regionSendKey"]; 179 retval.regionSendKey = (string) reader["regionSendKey"];
179 180
180 // Region Server 181 // Region Server
181 retval.regionDataURI = (string)reader["regionDataURI"]; 182 retval.regionDataURI = (string) reader["regionDataURI"];
182 retval.regionOnline = false; // Needs to be pinged before this can be set. 183 retval.regionOnline = false; // Needs to be pinged before this can be set.
183 retval.serverIP = (string)reader["serverIP"]; 184 retval.serverIP = (string) reader["serverIP"];
184 retval.serverPort = (uint)reader["serverPort"]; 185 retval.serverPort = (uint) reader["serverPort"];
185 retval.serverURI = (string)reader["serverURI"]; 186 retval.serverURI = (string) reader["serverURI"];
186 187
187 // Location 188 // Location
188 retval.regionLocX = (uint)((int)reader["locX"]); 189 retval.regionLocX = (uint) ((int) reader["locX"]);
189 retval.regionLocY = (uint)((int)reader["locY"]); 190 retval.regionLocY = (uint) ((int) reader["locY"]);
190 retval.regionLocZ = (uint)((int)reader["locZ"]); 191 retval.regionLocZ = (uint) ((int) reader["locZ"]);
191 192
192 // Neighbours - 0 = No Override 193 // Neighbours - 0 = No Override
193 retval.regionEastOverrideHandle = (ulong)reader["eastOverrideHandle"]; 194 retval.regionEastOverrideHandle = (ulong) reader["eastOverrideHandle"];
194 retval.regionWestOverrideHandle = (ulong)reader["westOverrideHandle"]; 195 retval.regionWestOverrideHandle = (ulong) reader["westOverrideHandle"];
195 retval.regionSouthOverrideHandle = (ulong)reader["southOverrideHandle"]; 196 retval.regionSouthOverrideHandle = (ulong) reader["southOverrideHandle"];
196 retval.regionNorthOverrideHandle = (ulong)reader["northOverrideHandle"]; 197 retval.regionNorthOverrideHandle = (ulong) reader["northOverrideHandle"];
197 198
198 // Assets 199 // Assets
199 retval.regionAssetURI = (string)reader["regionAssetURI"]; 200 retval.regionAssetURI = (string) reader["regionAssetURI"];
200 retval.regionAssetRecvKey = (string)reader["regionAssetRecvKey"]; 201 retval.regionAssetRecvKey = (string) reader["regionAssetRecvKey"];
201 retval.regionAssetSendKey = (string)reader["regionAssetSendKey"]; 202 retval.regionAssetSendKey = (string) reader["regionAssetSendKey"];
202 203
203 // Userserver 204 // Userserver
204 retval.regionUserURI = (string)reader["regionUserURI"]; 205 retval.regionUserURI = (string) reader["regionUserURI"];
205 retval.regionUserRecvKey = (string)reader["regionUserRecvKey"]; 206 retval.regionUserRecvKey = (string) reader["regionUserRecvKey"];
206 retval.regionUserSendKey = (string)reader["regionUserSendKey"]; 207 retval.regionUserSendKey = (string) reader["regionUserSendKey"];
207 } 208 }
208 else 209 else
209 { 210 {
@@ -219,12 +220,15 @@ namespace OpenSim.Framework.Data.SQLite
219 /// <returns>Success?</returns> 220 /// <returns>Success?</returns>
220 public bool insertRow(RegionProfileData profile) 221 public bool insertRow(RegionProfileData profile)
221 { 222 {
222 string sql = "REPLACE INTO regions VALUES (regionHandle, regionName, uuid, regionRecvKey, regionSecret, regionSendKey, regionDataURI, "; 223 string sql =
223 sql += "serverIP, serverPort, serverURI, locX, locY, locZ, eastOverrideHandle, westOverrideHandle, southOverrideHandle, northOverrideHandle, regionAssetURI, regionAssetRecvKey, "; 224 "REPLACE INTO regions VALUES (regionHandle, regionName, uuid, regionRecvKey, regionSecret, regionSendKey, regionDataURI, ";
225 sql +=
226 "serverIP, serverPort, serverURI, locX, locY, locZ, eastOverrideHandle, westOverrideHandle, southOverrideHandle, northOverrideHandle, regionAssetURI, regionAssetRecvKey, ";
224 sql += "regionAssetSendKey, regionUserURI, regionUserRecvKey, regionUserSendKey) VALUES "; 227 sql += "regionAssetSendKey, regionUserURI, regionUserRecvKey, regionUserSendKey) VALUES ";
225 228
226 sql += "(@regionHandle, @regionName, @uuid, @regionRecvKey, @regionSecret, @regionSendKey, @regionDataURI, "; 229 sql += "(@regionHandle, @regionName, @uuid, @regionRecvKey, @regionSecret, @regionSendKey, @regionDataURI, ";
227 sql += "@serverIP, @serverPort, @serverURI, @locX, @locY, @locZ, @eastOverrideHandle, @westOverrideHandle, @southOverrideHandle, @northOverrideHandle, @regionAssetURI, @regionAssetRecvKey, "; 230 sql +=
231 "@serverIP, @serverPort, @serverURI, @locX, @locY, @locZ, @eastOverrideHandle, @westOverrideHandle, @southOverrideHandle, @northOverrideHandle, @regionAssetURI, @regionAssetRecvKey, ";
228 sql += "@regionAssetSendKey, @regionUserURI, @regionUserRecvKey, @regionUserSendKey);"; 232 sql += "@regionAssetSendKey, @regionUserURI, @regionUserRecvKey, @regionUserSendKey);";
229 233
230 Dictionary<string, string> parameters = new Dictionary<string, string>(); 234 Dictionary<string, string> parameters = new Dictionary<string, string>();
@@ -271,4 +275,4 @@ namespace OpenSim.Framework.Data.SQLite
271 return returnval; 275 return returnval;
272 } 276 }
273 } 277 }
274} 278} \ No newline at end of file
diff --git a/OpenSim/Framework/Data.SQLite/SQLiteUserData.cs b/OpenSim/Framework/Data.SQLite/SQLiteUserData.cs
index 37a8be5..d7a6b39 100644
--- a/OpenSim/Framework/Data.SQLite/SQLiteUserData.cs
+++ b/OpenSim/Framework/Data.SQLite/SQLiteUserData.cs
@@ -26,12 +26,8 @@
26* 26*
27*/ 27*/
28using System; 28using System;
29using System.IO;
30using libsecondlife;
31using OpenSim.Framework;
32using OpenSim.Framework;
33using System.Data; 29using System.Data;
34using System.Data.SqlTypes; 30using libsecondlife;
35using Mono.Data.SqliteClient; 31using Mono.Data.SqliteClient;
36using OpenSim.Framework.Console; 32using OpenSim.Framework.Console;
37 33
@@ -45,30 +41,31 @@ namespace OpenSim.Framework.Data.SQLite
45 /// <summary> 41 /// <summary>
46 /// The database manager 42 /// The database manager
47 /// </summary> 43 /// </summary>
48
49 /// <summary> 44 /// <summary>
50 /// Artificial constructor called upon plugin load 45 /// Artificial constructor called upon plugin load
51 /// </summary> 46 /// </summary>
52 private const string userSelect = "select * from users"; 47 private const string userSelect = "select * from users";
48
53 private DataSet ds; 49 private DataSet ds;
54 private SqliteDataAdapter da; 50 private SqliteDataAdapter da;
55 51
56 public void Initialise() 52 public void Initialise()
57 { 53 {
58 SqliteConnection conn = new SqliteConnection("URI=file:userprofiles.db,version=3"); 54 SqliteConnection conn = new SqliteConnection("URI=file:userprofiles.db,version=3");
59 TestTables(conn); 55 TestTables(conn);
60 56
61 ds = new DataSet(); 57 ds = new DataSet();
62 da = new SqliteDataAdapter(new SqliteCommand(userSelect, conn)); 58 da = new SqliteDataAdapter(new SqliteCommand(userSelect, conn));
63 59
64 lock (ds) { 60 lock (ds)
61 {
65 ds.Tables.Add(createUsersTable()); 62 ds.Tables.Add(createUsersTable());
66 ds.Tables.Add(createUserAgentsTable()); 63 ds.Tables.Add(createUserAgentsTable());
67 64
68 setupUserCommands(da, conn); 65 setupUserCommands(da, conn);
69 da.Fill(ds.Tables["users"]); 66 da.Fill(ds.Tables["users"]);
70 } 67 }
71 68
72 return; 69 return;
73 } 70 }
74 71
@@ -79,16 +76,21 @@ namespace OpenSim.Framework.Data.SQLite
79 /// <returns>A user profile</returns> 76 /// <returns>A user profile</returns>
80 public UserProfileData GetUserByUUID(LLUUID uuid) 77 public UserProfileData GetUserByUUID(LLUUID uuid)
81 { 78 {
82 lock (ds) { 79 lock (ds)
80 {
83 DataRow row = ds.Tables["users"].Rows.Find(uuid); 81 DataRow row = ds.Tables["users"].Rows.Find(uuid);
84 if(row != null) { 82 if (row != null)
83 {
85 UserProfileData user = buildUserProfile(row); 84 UserProfileData user = buildUserProfile(row);
86 row = ds.Tables["useragents"].Rows.Find(uuid); 85 row = ds.Tables["useragents"].Rows.Find(uuid);
87 if(row != null) { 86 if (row != null)
87 {
88 user.currentAgent = buildUserAgent(row); 88 user.currentAgent = buildUserAgent(row);
89 } 89 }
90 return user; 90 return user;
91 } else { 91 }
92 else
93 {
92 return null; 94 return null;
93 } 95 }
94 } 96 }
@@ -113,16 +115,21 @@ namespace OpenSim.Framework.Data.SQLite
113 public UserProfileData GetUserByName(string fname, string lname) 115 public UserProfileData GetUserByName(string fname, string lname)
114 { 116 {
115 string select = "surname = '" + lname + "' and username = '" + fname + "'"; 117 string select = "surname = '" + lname + "' and username = '" + fname + "'";
116 lock (ds) { 118 lock (ds)
119 {
117 DataRow[] rows = ds.Tables["users"].Select(select); 120 DataRow[] rows = ds.Tables["users"].Select(select);
118 if(rows.Length > 0) { 121 if (rows.Length > 0)
122 {
119 UserProfileData user = buildUserProfile(rows[0]); 123 UserProfileData user = buildUserProfile(rows[0]);
120 DataRow row = ds.Tables["useragents"].Rows.Find(user.UUID); 124 DataRow row = ds.Tables["useragents"].Rows.Find(user.UUID);
121 if(row != null) { 125 if (row != null)
126 {
122 user.currentAgent = buildUserAgent(row); 127 user.currentAgent = buildUserAgent(row);
123 } 128 }
124 return user; 129 return user;
125 } else { 130 }
131 else
132 {
126 return null; 133 return null;
127 } 134 }
128 } 135 }
@@ -134,7 +141,7 @@ namespace OpenSim.Framework.Data.SQLite
134 /// <param name="uuid">The users account ID</param> 141 /// <param name="uuid">The users account ID</param>
135 /// <returns>A matching users profile</returns> 142 /// <returns>A matching users profile</returns>
136 public UserAgentData GetAgentByUUID(LLUUID uuid) 143 public UserAgentData GetAgentByUUID(LLUUID uuid)
137 { 144 {
138 try 145 try
139 { 146 {
140 return GetUserByUUID(uuid).currentAgent; 147 return GetUserByUUID(uuid).currentAgent;
@@ -165,7 +172,7 @@ namespace OpenSim.Framework.Data.SQLite
165 { 172 {
166 try 173 try
167 { 174 {
168 return GetUserByName(fname,lname).currentAgent; 175 return GetUserByName(fname, lname).currentAgent;
169 } 176 }
170 catch (Exception) 177 catch (Exception)
171 { 178 {
@@ -180,8 +187,9 @@ namespace OpenSim.Framework.Data.SQLite
180 public void AddNewUserProfile(UserProfileData user) 187 public void AddNewUserProfile(UserProfileData user)
181 { 188 {
182 DataTable users = ds.Tables["users"]; 189 DataTable users = ds.Tables["users"];
183 lock (ds) { 190 lock (ds)
184 DataRow row = users.Rows.Find(user.UUID); 191 {
192 DataRow row = users.Rows.Find(user.UUID);
185 if (row == null) 193 if (row == null)
186 { 194 {
187 row = users.NewRow(); 195 row = users.NewRow();
@@ -192,10 +200,11 @@ namespace OpenSim.Framework.Data.SQLite
192 { 200 {
193 fillUserRow(row, user); 201 fillUserRow(row, user);
194 } 202 }
195 203
196 if(user.currentAgent != null) { 204 if (user.currentAgent != null)
205 {
197 DataTable ua = ds.Tables["useragents"]; 206 DataTable ua = ds.Tables["useragents"];
198 row = ua.Rows.Find(user.UUID); 207 row = ua.Rows.Find(user.UUID);
199 if (row == null) 208 if (row == null)
200 { 209 {
201 row = ua.NewRow(); 210 row = ua.NewRow();
@@ -207,12 +216,13 @@ namespace OpenSim.Framework.Data.SQLite
207 fillUserAgentRow(row, user.currentAgent); 216 fillUserAgentRow(row, user.currentAgent);
208 } 217 }
209 } 218 }
210 MainLog.Instance.Verbose("SQLITE", "Syncing user database: " + ds.Tables["users"].Rows.Count + " users stored"); 219 MainLog.Instance.Verbose("SQLITE",
220 "Syncing user database: " + ds.Tables["users"].Rows.Count + " users stored");
211 // save changes off to disk 221 // save changes off to disk
212 da.Update(ds, "users"); 222 da.Update(ds, "users");
213 } 223 }
214 } 224 }
215 225
216 /// <summary> 226 /// <summary>
217 /// Creates a new user profile 227 /// Creates a new user profile
218 /// </summary> 228 /// </summary>
@@ -220,10 +230,13 @@ namespace OpenSim.Framework.Data.SQLite
220 /// <returns>True on success, false on error</returns> 230 /// <returns>True on success, false on error</returns>
221 public bool UpdateUserProfile(UserProfileData user) 231 public bool UpdateUserProfile(UserProfileData user)
222 { 232 {
223 try { 233 try
234 {
224 AddNewUserProfile(user); 235 AddNewUserProfile(user);
225 return true; 236 return true;
226 } catch (Exception) { 237 }
238 catch (Exception)
239 {
227 return false; 240 return false;
228 } 241 }
229 } 242 }
@@ -279,51 +292,51 @@ namespace OpenSim.Framework.Data.SQLite
279 { 292 {
280 return "0.1"; 293 return "0.1";
281 } 294 }
282 295
283 /*********************************************************************** 296 /***********************************************************************
284 * 297 *
285 * DataTable creation 298 * DataTable creation
286 * 299 *
287 **********************************************************************/ 300 **********************************************************************/
288 /*********************************************************************** 301 /***********************************************************************
289 * 302 *
290 * Database Definition Functions 303 * Database Definition Functions
291 * 304 *
292 * This should be db agnostic as we define them in ADO.NET terms 305 * This should be db agnostic as we define them in ADO.NET terms
293 * 306 *
294 **********************************************************************/ 307 **********************************************************************/
295 308
296 private DataTable createUsersTable() 309 private DataTable createUsersTable()
297 { 310 {
298 DataTable users = new DataTable("users"); 311 DataTable users = new DataTable("users");
299 312
300 createCol(users, "UUID", typeof(System.String)); 313 createCol(users, "UUID", typeof (String));
301 createCol(users, "username", typeof(System.String)); 314 createCol(users, "username", typeof (String));
302 createCol(users, "surname", typeof(System.String)); 315 createCol(users, "surname", typeof (String));
303 createCol(users, "passwordHash", typeof(System.String)); 316 createCol(users, "passwordHash", typeof (String));
304 createCol(users, "passwordSalt", typeof(System.String)); 317 createCol(users, "passwordSalt", typeof (String));
305 318
306 createCol(users, "homeRegionX", typeof(System.Int32)); 319 createCol(users, "homeRegionX", typeof (Int32));
307 createCol(users, "homeRegionY", typeof(System.Int32)); 320 createCol(users, "homeRegionY", typeof (Int32));
308 createCol(users, "homeLocationX", typeof(System.Double)); 321 createCol(users, "homeLocationX", typeof (Double));
309 createCol(users, "homeLocationY", typeof(System.Double)); 322 createCol(users, "homeLocationY", typeof (Double));
310 createCol(users, "homeLocationZ", typeof(System.Double)); 323 createCol(users, "homeLocationZ", typeof (Double));
311 createCol(users, "homeLookAtX", typeof(System.Double)); 324 createCol(users, "homeLookAtX", typeof (Double));
312 createCol(users, "homeLookAtY", typeof(System.Double)); 325 createCol(users, "homeLookAtY", typeof (Double));
313 createCol(users, "homeLookAtZ", typeof(System.Double)); 326 createCol(users, "homeLookAtZ", typeof (Double));
314 createCol(users, "created", typeof(System.Int32)); 327 createCol(users, "created", typeof (Int32));
315 createCol(users, "lastLogin", typeof(System.Int32)); 328 createCol(users, "lastLogin", typeof (Int32));
316 createCol(users, "rootInventoryFolderID", typeof(System.String)); 329 createCol(users, "rootInventoryFolderID", typeof (String));
317 createCol(users, "userInventoryURI", typeof(System.String)); 330 createCol(users, "userInventoryURI", typeof (String));
318 createCol(users, "userAssetURI", typeof(System.String)); 331 createCol(users, "userAssetURI", typeof (String));
319 createCol(users, "profileCanDoMask", typeof(System.Int32)); 332 createCol(users, "profileCanDoMask", typeof (Int32));
320 createCol(users, "profileWantDoMask", typeof(System.Int32)); 333 createCol(users, "profileWantDoMask", typeof (Int32));
321 createCol(users, "profileAboutText", typeof(System.String)); 334 createCol(users, "profileAboutText", typeof (String));
322 createCol(users, "profileFirstText", typeof(System.String)); 335 createCol(users, "profileFirstText", typeof (String));
323 createCol(users, "profileImage", typeof(System.String)); 336 createCol(users, "profileImage", typeof (String));
324 createCol(users, "profileFirstImage", typeof(System.String)); 337 createCol(users, "profileFirstImage", typeof (String));
325 // Add in contraints 338 // Add in contraints
326 users.PrimaryKey = new DataColumn[] { users.Columns["UUID"] }; 339 users.PrimaryKey = new DataColumn[] {users.Columns["UUID"]};
327 return users; 340 return users;
328 } 341 }
329 342
@@ -331,27 +344,27 @@ namespace OpenSim.Framework.Data.SQLite
331 { 344 {
332 DataTable ua = new DataTable("useragents"); 345 DataTable ua = new DataTable("useragents");
333 // this is the UUID of the user 346 // this is the UUID of the user
334 createCol(ua, "UUID", typeof(System.String)); 347 createCol(ua, "UUID", typeof (String));
335 createCol(ua, "agentIP", typeof(System.String)); 348 createCol(ua, "agentIP", typeof (String));
336 createCol(ua, "agentPort", typeof(System.Int32)); 349 createCol(ua, "agentPort", typeof (Int32));
337 createCol(ua, "agentOnline", typeof(System.Boolean)); 350 createCol(ua, "agentOnline", typeof (Boolean));
338 createCol(ua, "sessionID", typeof(System.String)); 351 createCol(ua, "sessionID", typeof (String));
339 createCol(ua, "secureSessionID", typeof(System.String)); 352 createCol(ua, "secureSessionID", typeof (String));
340 createCol(ua, "regionID", typeof(System.String)); 353 createCol(ua, "regionID", typeof (String));
341 createCol(ua, "loginTime", typeof(System.Int32)); 354 createCol(ua, "loginTime", typeof (Int32));
342 createCol(ua, "logoutTime", typeof(System.Int32)); 355 createCol(ua, "logoutTime", typeof (Int32));
343 createCol(ua, "currentRegion", typeof(System.String)); 356 createCol(ua, "currentRegion", typeof (String));
344 createCol(ua, "currentHandle", typeof(System.Int32)); 357 createCol(ua, "currentHandle", typeof (Int32));
345 // vectors 358 // vectors
346 createCol(ua, "currentPosX", typeof(System.Double)); 359 createCol(ua, "currentPosX", typeof (Double));
347 createCol(ua, "currentPosY", typeof(System.Double)); 360 createCol(ua, "currentPosY", typeof (Double));
348 createCol(ua, "currentPosZ", typeof(System.Double)); 361 createCol(ua, "currentPosZ", typeof (Double));
349 // constraints 362 // constraints
350 ua.PrimaryKey = new DataColumn[] { ua.Columns["UUID"] }; 363 ua.PrimaryKey = new DataColumn[] {ua.Columns["UUID"]};
351 364
352 return ua; 365 return ua;
353 } 366 }
354 367
355 /*********************************************************************** 368 /***********************************************************************
356 * 369 *
357 * Convert between ADO.NET <=> OpenSim Objects 370 * Convert between ADO.NET <=> OpenSim Objects
@@ -366,35 +379,35 @@ namespace OpenSim.Framework.Data.SQLite
366 // interesting has to be done to actually get these values 379 // interesting has to be done to actually get these values
367 // back out. Not enough time to figure it out yet. 380 // back out. Not enough time to figure it out yet.
368 UserProfileData user = new UserProfileData(); 381 UserProfileData user = new UserProfileData();
369 user.UUID = new LLUUID((String)row["UUID"]); 382 user.UUID = new LLUUID((String) row["UUID"]);
370 user.username = (String)row["username"]; 383 user.username = (String) row["username"];
371 user.surname = (String)row["surname"]; 384 user.surname = (String) row["surname"];
372 user.passwordHash = (String)row["passwordHash"]; 385 user.passwordHash = (String) row["passwordHash"];
373 user.passwordSalt = (String)row["passwordSalt"]; 386 user.passwordSalt = (String) row["passwordSalt"];
374 387
375 user.homeRegionX = Convert.ToUInt32(row["homeRegionX"]); 388 user.homeRegionX = Convert.ToUInt32(row["homeRegionX"]);
376 user.homeRegionY = Convert.ToUInt32(row["homeRegionY"]); 389 user.homeRegionY = Convert.ToUInt32(row["homeRegionY"]);
377 user.homeLocation = new LLVector3( 390 user.homeLocation = new LLVector3(
378 Convert.ToSingle(row["homeLocationX"]), 391 Convert.ToSingle(row["homeLocationX"]),
379 Convert.ToSingle(row["homeLocationY"]), 392 Convert.ToSingle(row["homeLocationY"]),
380 Convert.ToSingle(row["homeLocationZ"]) 393 Convert.ToSingle(row["homeLocationZ"])
381 ); 394 );
382 user.homeLookAt = new LLVector3( 395 user.homeLookAt = new LLVector3(
383 Convert.ToSingle(row["homeLookAtX"]), 396 Convert.ToSingle(row["homeLookAtX"]),
384 Convert.ToSingle(row["homeLookAtY"]), 397 Convert.ToSingle(row["homeLookAtY"]),
385 Convert.ToSingle(row["homeLookAtZ"]) 398 Convert.ToSingle(row["homeLookAtZ"])
386 ); 399 );
387 user.created = Convert.ToInt32(row["created"]); 400 user.created = Convert.ToInt32(row["created"]);
388 user.lastLogin = Convert.ToInt32(row["lastLogin"]); 401 user.lastLogin = Convert.ToInt32(row["lastLogin"]);
389 user.rootInventoryFolderID = new LLUUID((String)row["rootInventoryFolderID"]); 402 user.rootInventoryFolderID = new LLUUID((String) row["rootInventoryFolderID"]);
390 user.userInventoryURI = (String)row["userInventoryURI"]; 403 user.userInventoryURI = (String) row["userInventoryURI"];
391 user.userAssetURI = (String)row["userAssetURI"]; 404 user.userAssetURI = (String) row["userAssetURI"];
392 user.profileCanDoMask = Convert.ToUInt32(row["profileCanDoMask"]); 405 user.profileCanDoMask = Convert.ToUInt32(row["profileCanDoMask"]);
393 user.profileWantDoMask = Convert.ToUInt32(row["profileWantDoMask"]); 406 user.profileWantDoMask = Convert.ToUInt32(row["profileWantDoMask"]);
394 user.profileAboutText = (String)row["profileAboutText"]; 407 user.profileAboutText = (String) row["profileAboutText"];
395 user.profileFirstText = (String)row["profileFirstText"]; 408 user.profileFirstText = (String) row["profileFirstText"];
396 user.profileImage = new LLUUID((String)row["profileImage"]); 409 user.profileImage = new LLUUID((String) row["profileImage"]);
397 user.profileFirstImage = new LLUUID((String)row["profileFirstImage"]); 410 user.profileFirstImage = new LLUUID((String) row["profileFirstImage"]);
398 return user; 411 return user;
399 } 412 }
400 413
@@ -405,8 +418,8 @@ namespace OpenSim.Framework.Data.SQLite
405 row["surname"] = user.surname; 418 row["surname"] = user.surname;
406 row["passwordHash"] = user.passwordHash; 419 row["passwordHash"] = user.passwordHash;
407 row["passwordSalt"] = user.passwordSalt; 420 row["passwordSalt"] = user.passwordSalt;
408 421
409 422
410 row["homeRegionX"] = user.homeRegionX; 423 row["homeRegionX"] = user.homeRegionX;
411 row["homeRegionY"] = user.homeRegionY; 424 row["homeRegionY"] = user.homeRegionY;
412 row["homeLocationX"] = user.homeLocation.X; 425 row["homeLocationX"] = user.homeLocation.X;
@@ -427,10 +440,12 @@ namespace OpenSim.Framework.Data.SQLite
427 row["profileFirstText"] = user.profileFirstText; 440 row["profileFirstText"] = user.profileFirstText;
428 row["profileImage"] = user.profileImage; 441 row["profileImage"] = user.profileImage;
429 row["profileFirstImage"] = user.profileFirstImage; 442 row["profileFirstImage"] = user.profileFirstImage;
430 443
431 // ADO.NET doesn't handle NULL very well 444 // ADO.NET doesn't handle NULL very well
432 foreach (DataColumn col in ds.Tables["users"].Columns) { 445 foreach (DataColumn col in ds.Tables["users"].Columns)
433 if (row[col] == null) { 446 {
447 if (row[col] == null)
448 {
434 row[col] = ""; 449 row[col] = "";
435 } 450 }
436 } 451 }
@@ -439,33 +454,33 @@ namespace OpenSim.Framework.Data.SQLite
439 private UserAgentData buildUserAgent(DataRow row) 454 private UserAgentData buildUserAgent(DataRow row)
440 { 455 {
441 UserAgentData ua = new UserAgentData(); 456 UserAgentData ua = new UserAgentData();
442 457
443 ua.UUID = new LLUUID((String)row["UUID"]); 458 ua.UUID = new LLUUID((String) row["UUID"]);
444 ua.agentIP = (String)row["agentIP"]; 459 ua.agentIP = (String) row["agentIP"];
445 ua.agentPort = Convert.ToUInt32(row["agentPort"]); 460 ua.agentPort = Convert.ToUInt32(row["agentPort"]);
446 ua.agentOnline = Convert.ToBoolean(row["agentOnline"]); 461 ua.agentOnline = Convert.ToBoolean(row["agentOnline"]);
447 ua.sessionID = new LLUUID((String)row["sessionID"]); 462 ua.sessionID = new LLUUID((String) row["sessionID"]);
448 ua.secureSessionID = new LLUUID((String)row["secureSessionID"]); 463 ua.secureSessionID = new LLUUID((String) row["secureSessionID"]);
449 ua.regionID = new LLUUID((String)row["regionID"]); 464 ua.regionID = new LLUUID((String) row["regionID"]);
450 ua.loginTime = Convert.ToInt32(row["loginTime"]); 465 ua.loginTime = Convert.ToInt32(row["loginTime"]);
451 ua.logoutTime = Convert.ToInt32(row["logoutTime"]); 466 ua.logoutTime = Convert.ToInt32(row["logoutTime"]);
452 ua.currentRegion = new LLUUID((String)row["currentRegion"]); 467 ua.currentRegion = new LLUUID((String) row["currentRegion"]);
453 ua.currentHandle = Convert.ToUInt32(row["currentHandle"]); 468 ua.currentHandle = Convert.ToUInt32(row["currentHandle"]);
454 ua.currentPos = new LLVector3( 469 ua.currentPos = new LLVector3(
455 Convert.ToSingle(row["currentPosX"]), 470 Convert.ToSingle(row["currentPosX"]),
456 Convert.ToSingle(row["currentPosY"]), 471 Convert.ToSingle(row["currentPosY"]),
457 Convert.ToSingle(row["currentPosZ"]) 472 Convert.ToSingle(row["currentPosZ"])
458 ); 473 );
459 return ua; 474 return ua;
460 } 475 }
461 476
462 private void fillUserAgentRow(DataRow row, UserAgentData ua) 477 private void fillUserAgentRow(DataRow row, UserAgentData ua)
463 { 478 {
464 row["UUID"] = ua.UUID; 479 row["UUID"] = ua.UUID;
465 row["agentIP"] = ua.agentIP; 480 row["agentIP"] = ua.agentIP;
466 row["agentPort"] = ua.agentPort; 481 row["agentPort"] = ua.agentPort;
467 row["agentOnline"] = ua.agentOnline; 482 row["agentOnline"] = ua.agentOnline;
468 row["sessionID"] = ua.sessionID; 483 row["sessionID"] = ua.sessionID;
469 row["secureSessionID"] = ua.secureSessionID; 484 row["secureSessionID"] = ua.secureSessionID;
470 row["regionID"] = ua.regionID; 485 row["regionID"] = ua.regionID;
471 row["loginTime"] = ua.loginTime; 486 row["loginTime"] = ua.loginTime;
@@ -496,18 +511,18 @@ namespace OpenSim.Framework.Data.SQLite
496 da.UpdateCommand.Connection = conn; 511 da.UpdateCommand.Connection = conn;
497 512
498 SqliteCommand delete = new SqliteCommand("delete from users where UUID = :UUID"); 513 SqliteCommand delete = new SqliteCommand("delete from users where UUID = :UUID");
499 delete.Parameters.Add(createSqliteParameter("UUID", typeof(System.String))); 514 delete.Parameters.Add(createSqliteParameter("UUID", typeof (String)));
500 delete.Connection = conn; 515 delete.Connection = conn;
501 da.DeleteCommand = delete; 516 da.DeleteCommand = delete;
502 } 517 }
503 518
504 private void InitDB(SqliteConnection conn) 519 private void InitDB(SqliteConnection conn)
505 { 520 {
506 string createUsers = defineTable(createUsersTable()); 521 string createUsers = defineTable(createUsersTable());
507 SqliteCommand pcmd = new SqliteCommand(createUsers, conn); 522 SqliteCommand pcmd = new SqliteCommand(createUsers, conn);
508 conn.Open(); 523 conn.Open();
509 pcmd.ExecuteNonQuery(); 524 pcmd.ExecuteNonQuery();
510 conn.Close(); 525 conn.Close();
511 } 526 }
512 527
513 private bool TestTables(SqliteConnection conn) 528 private bool TestTables(SqliteConnection conn)
@@ -515,14 +530,16 @@ namespace OpenSim.Framework.Data.SQLite
515 SqliteCommand cmd = new SqliteCommand(userSelect, conn); 530 SqliteCommand cmd = new SqliteCommand(userSelect, conn);
516 SqliteDataAdapter pDa = new SqliteDataAdapter(cmd); 531 SqliteDataAdapter pDa = new SqliteDataAdapter(cmd);
517 DataSet tmpDS = new DataSet(); 532 DataSet tmpDS = new DataSet();
518 try { 533 try
534 {
519 pDa.Fill(tmpDS, "users"); 535 pDa.Fill(tmpDS, "users");
520 } catch (Mono.Data.SqliteClient.SqliteSyntaxException) { 536 }
537 catch (SqliteSyntaxException)
538 {
521 MainLog.Instance.Verbose("DATASTORE", "SQLite Database doesn't exist... creating"); 539 MainLog.Instance.Verbose("DATASTORE", "SQLite Database doesn't exist... creating");
522 InitDB(conn); 540 InitDB(conn);
523 } 541 }
524 return true; 542 return true;
525 } 543 }
526
527 } 544 }
528} 545} \ No newline at end of file
diff --git a/OpenSim/Framework/Data/GridData.cs b/OpenSim/Framework/Data/GridData.cs
index 2a5b8f6..b3b6ed7 100644
--- a/OpenSim/Framework/Data/GridData.cs
+++ b/OpenSim/Framework/Data/GridData.cs
@@ -106,6 +106,5 @@ namespace OpenSim.Framework.Data
106 DataResponse AddProfile(RegionProfileData profile); 106 DataResponse AddProfile(RegionProfileData profile);
107 107
108 ReservationData GetReservationAtPoint(uint x, uint y); 108 ReservationData GetReservationAtPoint(uint x, uint y);
109
110 } 109 }
111} 110} \ No newline at end of file
diff --git a/OpenSim/Framework/Data/ILogData.cs b/OpenSim/Framework/Data/ILogData.cs
index b222a28..373d8e1 100644
--- a/OpenSim/Framework/Data/ILogData.cs
+++ b/OpenSim/Framework/Data/ILogData.cs
@@ -63,7 +63,9 @@ namespace OpenSim.Framework.Data
63 /// </summary> 63 /// </summary>
64 public interface ILogData 64 public interface ILogData
65 { 65 {
66 void saveLog(string serverDaemon, string target, string methodCall, string arguments, int priority,string logMessage); 66 void saveLog(string serverDaemon, string target, string methodCall, string arguments, int priority,
67 string logMessage);
68
67 /// <summary> 69 /// <summary>
68 /// Initialises the interface 70 /// Initialises the interface
69 /// </summary> 71 /// </summary>
@@ -86,5 +88,4 @@ namespace OpenSim.Framework.Data
86 /// <returns>A string containing the plugin version</returns> 88 /// <returns>A string containing the plugin version</returns>
87 string getVersion(); 89 string getVersion();
88 } 90 }
89 91} \ No newline at end of file
90}
diff --git a/OpenSim/Framework/Data/IniConfig.cs b/OpenSim/Framework/Data/IniConfig.cs
index f0f63b4..048b491 100644
--- a/OpenSim/Framework/Data/IniConfig.cs
+++ b/OpenSim/Framework/Data/IniConfig.cs
@@ -27,6 +27,7 @@
27*/ 27*/
28using System.IO; 28using System.IO;
29using System.Text.RegularExpressions; 29using System.Text.RegularExpressions;
30
30/* 31/*
31 Taken from public code listing at by Alex Pinsker 32 Taken from public code listing at by Alex Pinsker
32 http://alexpinsker.blogspot.com/2005/12/reading-ini-file-from-c_113432097333021549.html 33 http://alexpinsker.blogspot.com/2005/12/reading-ini-file-from-c_113432097333021549.html
@@ -52,7 +53,8 @@ namespace OpenSim.Framework.Data
52 RegexOptions.Compiled | 53 RegexOptions.Compiled |
53 RegexOptions.CultureInvariant); 54 RegexOptions.CultureInvariant);
54 } 55 }
55 static private Regex _iniKeyValuePatternRegex; 56
57 private static Regex _iniKeyValuePatternRegex;
56 58
57 public IniFile(string iniFileName) 59 public IniFile(string iniFileName)
58 { 60 {
@@ -62,7 +64,7 @@ namespace OpenSim.Framework.Data
62 public string ParseFileReadValue(string key) 64 public string ParseFileReadValue(string key)
63 { 65 {
64 using (StreamReader reader = 66 using (StreamReader reader =
65 new StreamReader(_iniFileName)) 67 new StreamReader(_iniFileName))
66 { 68 {
67 do 69 do
68 { 70 {
@@ -72,18 +74,16 @@ namespace OpenSim.Framework.Data
72 if (match.Success) 74 if (match.Success)
73 { 75 {
74 string currentKey = 76 string currentKey =
75 match.Groups["Key"].Value as string; 77 match.Groups["Key"].Value as string;
76 if (currentKey != null && 78 if (currentKey != null &&
77 currentKey.Trim().CompareTo(key) == 0) 79 currentKey.Trim().CompareTo(key) == 0)
78 { 80 {
79 string value = 81 string value =
80 match.Groups["Value"].Value as string; 82 match.Groups["Value"].Value as string;
81 return value; 83 return value;
82 } 84 }
83 } 85 }
84 86 } while (reader.Peek() != -1);
85 }
86 while (reader.Peek() != -1);
87 } 87 }
88 return null; 88 return null;
89 } 89 }
@@ -91,6 +91,8 @@ namespace OpenSim.Framework.Data
91 public string IniFileName 91 public string IniFileName
92 { 92 {
93 get { return _iniFileName; } 93 get { return _iniFileName; }
94 } private string _iniFileName; 94 }
95
96 private string _iniFileName;
95 } 97 }
96} 98} \ No newline at end of file
diff --git a/OpenSim/Framework/Data/Properties/AssemblyInfo.cs b/OpenSim/Framework/Data/Properties/AssemblyInfo.cs
index 556d589..51050d1 100644
--- a/OpenSim/Framework/Data/Properties/AssemblyInfo.cs
+++ b/OpenSim/Framework/Data/Properties/AssemblyInfo.cs
@@ -1,24 +1,28 @@
1using System.Reflection; 1using System.Reflection;
2using System.Runtime.InteropServices; 2using System.Runtime.InteropServices;
3
3// General Information about an assembly is controlled through the following 4// General Information about an assembly is controlled through the following
4// set of attributes. Change these attribute values to modify the information 5// set of attributes. Change these attribute values to modify the information
5// associated with an assembly. 6// associated with an assembly.
6[assembly: AssemblyTitle("OpenSim.Framework.Data")] 7
7[assembly: AssemblyDescription("")] 8[assembly : AssemblyTitle("OpenSim.Framework.Data")]
8[assembly: AssemblyConfiguration("")] 9[assembly : AssemblyDescription("")]
9[assembly: AssemblyCompany("")] 10[assembly : AssemblyConfiguration("")]
10[assembly: AssemblyProduct("OpenSim.Framework.Data")] 11[assembly : AssemblyCompany("")]
11[assembly: AssemblyCopyright("Copyright © 2007")] 12[assembly : AssemblyProduct("OpenSim.Framework.Data")]
12[assembly: AssemblyTrademark("")] 13[assembly : AssemblyCopyright("Copyright © 2007")]
13[assembly: AssemblyCulture("")] 14[assembly : AssemblyTrademark("")]
15[assembly : AssemblyCulture("")]
14 16
15// Setting ComVisible to false makes the types in this assembly not visible 17// Setting ComVisible to false makes the types in this assembly not visible
16// to COM components. If you need to access a type in this assembly from 18// to COM components. If you need to access a type in this assembly from
17// COM, set the ComVisible attribute to true on that type. 19// COM, set the ComVisible attribute to true on that type.
18[assembly: ComVisible(false)] 20
21[assembly : ComVisible(false)]
19 22
20// The following GUID is for the ID of the typelib if this project is exposed to COM 23// The following GUID is for the ID of the typelib if this project is exposed to COM
21[assembly: Guid("3a711c34-b0c0-4264-b0fe-f366eabf9d7b")] 24
25[assembly : Guid("3a711c34-b0c0-4264-b0fe-f366eabf9d7b")]
22 26
23// Version information for an assembly consists of the following four values: 27// Version information for an assembly consists of the following four values:
24// 28//
@@ -29,5 +33,6 @@ using System.Runtime.InteropServices;
29// 33//
30// You can specify all the values or you can default the Revision and Build Numbers 34// You can specify all the values or you can default the Revision and Build Numbers
31// by using the '*' as shown below: 35// by using the '*' as shown below:
32[assembly: AssemblyVersion("1.0.0.0")] 36
33[assembly: AssemblyFileVersion("1.0.0.0")] 37[assembly : AssemblyVersion("1.0.0.0")]
38[assembly : AssemblyFileVersion("1.0.0.0")] \ No newline at end of file
diff --git a/OpenSim/Framework/Data/RegionProfileData.cs b/OpenSim/Framework/Data/RegionProfileData.cs
index 5e5dac6..ab8771a 100644
--- a/OpenSim/Framework/Data/RegionProfileData.cs
+++ b/OpenSim/Framework/Data/RegionProfileData.cs
@@ -25,11 +25,11 @@
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28using libsecondlife;
29using Nwc.XmlRpc;
30 28
31using System; 29using System;
32using System.Collections; 30using System.Collections;
31using libsecondlife;
32using Nwc.XmlRpc;
33 33
34namespace OpenSim.Framework.Data 34namespace OpenSim.Framework.Data
35{ 35{
@@ -57,6 +57,7 @@ namespace OpenSim.Framework.Data
57 /// Coordinates of the region 57 /// Coordinates of the region
58 /// </summary> 58 /// </summary>
59 public uint regionLocX; 59 public uint regionLocX;
60
60 public uint regionLocY; 61 public uint regionLocY;
61 public uint regionLocZ; // Reserved (round-robin, layers, etc) 62 public uint regionLocZ; // Reserved (round-robin, layers, etc)
62 63
@@ -65,6 +66,7 @@ namespace OpenSim.Framework.Data
65 /// </summary> 66 /// </summary>
66 /// <remarks>Not very secure, needs improvement.</remarks> 67 /// <remarks>Not very secure, needs improvement.</remarks>
67 public string regionSendKey = ""; 68 public string regionSendKey = "";
69
68 public string regionRecvKey = ""; 70 public string regionRecvKey = "";
69 public string regionSecret = ""; 71 public string regionSecret = "";
70 72
@@ -77,6 +79,7 @@ namespace OpenSim.Framework.Data
77 /// Information about the server that the region is currently hosted on 79 /// Information about the server that the region is currently hosted on
78 /// </summary> 80 /// </summary>
79 public string serverIP = ""; 81 public string serverIP = "";
82
80 public uint serverPort; 83 public uint serverPort;
81 public string serverURI = ""; 84 public string serverURI = "";
82 85
@@ -88,6 +91,7 @@ namespace OpenSim.Framework.Data
88 /// Set of optional overrides. Can be used to create non-eulicidean spaces. 91 /// Set of optional overrides. Can be used to create non-eulicidean spaces.
89 /// </summary> 92 /// </summary>
90 public ulong regionNorthOverrideHandle; 93 public ulong regionNorthOverrideHandle;
94
91 public ulong regionSouthOverrideHandle; 95 public ulong regionSouthOverrideHandle;
92 public ulong regionEastOverrideHandle; 96 public ulong regionEastOverrideHandle;
93 public ulong regionWestOverrideHandle; 97 public ulong regionWestOverrideHandle;
@@ -102,6 +106,7 @@ namespace OpenSim.Framework.Data
102 /// Region Asset Details 106 /// Region Asset Details
103 /// </summary> 107 /// </summary>
104 public string regionAssetURI = ""; 108 public string regionAssetURI = "";
109
105 public string regionAssetSendKey = ""; 110 public string regionAssetSendKey = "";
106 public string regionAssetRecvKey = ""; 111 public string regionAssetRecvKey = "";
107 112
@@ -109,6 +114,7 @@ namespace OpenSim.Framework.Data
109 /// Region Userserver Details 114 /// Region Userserver Details
110 /// </summary> 115 /// </summary>
111 public string regionUserURI = ""; 116 public string regionUserURI = "";
117
112 public string regionUserSendKey = ""; 118 public string regionUserSendKey = "";
113 public string regionUserRecvKey = ""; 119 public string regionUserRecvKey = "";
114 120
@@ -124,7 +130,8 @@ namespace OpenSim.Framework.Data
124 /// <param name="gridserver_url"></param> 130 /// <param name="gridserver_url"></param>
125 /// <param name="?"></param> 131 /// <param name="?"></param>
126 /// <returns></returns> 132 /// <returns></returns>
127 public RegionProfileData RequestSimProfileData(LLUUID region_uuid, string gridserver_url, string gridserver_sendkey, string gridserver_recvkey) 133 public RegionProfileData RequestSimProfileData(LLUUID region_uuid, string gridserver_url,
134 string gridserver_sendkey, string gridserver_recvkey)
128 { 135 {
129 Hashtable requestData = new Hashtable(); 136 Hashtable requestData = new Hashtable();
130 requestData["region_uuid"] = region_uuid.UUID.ToString(); 137 requestData["region_uuid"] = region_uuid.UUID.ToString();
@@ -134,7 +141,7 @@ namespace OpenSim.Framework.Data
134 XmlRpcRequest GridReq = new XmlRpcRequest("simulator_data_request", SendParams); 141 XmlRpcRequest GridReq = new XmlRpcRequest("simulator_data_request", SendParams);
135 XmlRpcResponse GridResp = GridReq.Send(gridserver_url, 3000); 142 XmlRpcResponse GridResp = GridReq.Send(gridserver_url, 3000);
136 143
137 Hashtable responseData = (Hashtable)GridResp.Value; 144 Hashtable responseData = (Hashtable) GridResp.Value;
138 145
139 if (responseData.ContainsKey("error")) 146 if (responseData.ContainsKey("error"))
140 { 147 {
@@ -142,21 +149,23 @@ namespace OpenSim.Framework.Data
142 } 149 }
143 150
144 RegionProfileData simData = new RegionProfileData(); 151 RegionProfileData simData = new RegionProfileData();
145 simData.regionLocX = Convert.ToUInt32((string)responseData["region_locx"]); 152 simData.regionLocX = Convert.ToUInt32((string) responseData["region_locx"]);
146 simData.regionLocY = Convert.ToUInt32((string)responseData["region_locy"]); 153 simData.regionLocY = Convert.ToUInt32((string) responseData["region_locy"]);
147 simData.regionHandle = Helpers.UIntsToLong((simData.regionLocX * 256), (simData.regionLocY * 256)); 154 simData.regionHandle = Helpers.UIntsToLong((simData.regionLocX*256), (simData.regionLocY*256));
148 simData.serverIP = (string)responseData["sim_ip"]; 155 simData.serverIP = (string) responseData["sim_ip"];
149 simData.serverPort = Convert.ToUInt32((string)responseData["sim_port"]); 156 simData.serverPort = Convert.ToUInt32((string) responseData["sim_port"]);
150 simData.httpPort = Convert.ToUInt32((string)responseData["http_port"]); 157 simData.httpPort = Convert.ToUInt32((string) responseData["http_port"]);
151 simData.remotingPort = Convert.ToUInt32((string)responseData["remoting_port"]); 158 simData.remotingPort = Convert.ToUInt32((string) responseData["remoting_port"]);
152 simData.serverURI = "http://" + simData.serverIP + ":" + simData.serverPort.ToString() + "/"; 159 simData.serverURI = "http://" + simData.serverIP + ":" + simData.serverPort.ToString() + "/";
153 simData.httpServerURI = "http://" + simData.serverIP + ":" + simData.httpPort.ToString() + "/"; 160 simData.httpServerURI = "http://" + simData.serverIP + ":" + simData.httpPort.ToString() + "/";
154 simData.UUID = new LLUUID((string)responseData["region_UUID"]); 161 simData.UUID = new LLUUID((string) responseData["region_UUID"]);
155 simData.regionName = (string)responseData["region_name"]; 162 simData.regionName = (string) responseData["region_name"];
156 163
157 return simData; 164 return simData;
158 } 165 }
159 public RegionProfileData RequestSimProfileData(ulong region_handle, string gridserver_url, string gridserver_sendkey, string gridserver_recvkey) 166
167 public RegionProfileData RequestSimProfileData(ulong region_handle, string gridserver_url,
168 string gridserver_sendkey, string gridserver_recvkey)
160 { 169 {
161 Hashtable requestData = new Hashtable(); 170 Hashtable requestData = new Hashtable();
162 requestData["region_handle"] = region_handle.ToString(); 171 requestData["region_handle"] = region_handle.ToString();
@@ -166,7 +175,7 @@ namespace OpenSim.Framework.Data
166 XmlRpcRequest GridReq = new XmlRpcRequest("simulator_data_request", SendParams); 175 XmlRpcRequest GridReq = new XmlRpcRequest("simulator_data_request", SendParams);
167 XmlRpcResponse GridResp = GridReq.Send(gridserver_url, 3000); 176 XmlRpcResponse GridResp = GridReq.Send(gridserver_url, 3000);
168 177
169 Hashtable responseData = (Hashtable)GridResp.Value; 178 Hashtable responseData = (Hashtable) GridResp.Value;
170 179
171 if (responseData.ContainsKey("error")) 180 if (responseData.ContainsKey("error"))
172 { 181 {
@@ -174,19 +183,19 @@ namespace OpenSim.Framework.Data
174 } 183 }
175 184
176 RegionProfileData simData = new RegionProfileData(); 185 RegionProfileData simData = new RegionProfileData();
177 simData.regionLocX = Convert.ToUInt32((string)responseData["region_locx"]); 186 simData.regionLocX = Convert.ToUInt32((string) responseData["region_locx"]);
178 simData.regionLocY = Convert.ToUInt32((string)responseData["region_locy"]); 187 simData.regionLocY = Convert.ToUInt32((string) responseData["region_locy"]);
179 simData.regionHandle = Helpers.UIntsToLong((simData.regionLocX * 256), (simData.regionLocY * 256)); 188 simData.regionHandle = Helpers.UIntsToLong((simData.regionLocX*256), (simData.regionLocY*256));
180 simData.serverIP = (string)responseData["sim_ip"]; 189 simData.serverIP = (string) responseData["sim_ip"];
181 simData.serverPort = Convert.ToUInt32((string)responseData["sim_port"]); 190 simData.serverPort = Convert.ToUInt32((string) responseData["sim_port"]);
182 simData.httpPort = Convert.ToUInt32((string)responseData["http_port"]); 191 simData.httpPort = Convert.ToUInt32((string) responseData["http_port"]);
183 simData.remotingPort = Convert.ToUInt32((string)responseData["remoting_port"]); 192 simData.remotingPort = Convert.ToUInt32((string) responseData["remoting_port"]);
184 simData.httpServerURI = "http://" + simData.serverIP + ":" + simData.httpPort.ToString() + "/"; 193 simData.httpServerURI = "http://" + simData.serverIP + ":" + simData.httpPort.ToString() + "/";
185 simData.serverURI = "http://" + simData.serverIP + ":" + simData.serverPort.ToString() + "/"; 194 simData.serverURI = "http://" + simData.serverIP + ":" + simData.serverPort.ToString() + "/";
186 simData.UUID = new LLUUID((string)responseData["region_UUID"]); 195 simData.UUID = new LLUUID((string) responseData["region_UUID"]);
187 simData.regionName = (string)responseData["region_name"]; 196 simData.regionName = (string) responseData["region_name"];
188 197
189 return simData; 198 return simData;
190 } 199 }
191 } 200 }
192} 201} \ No newline at end of file
diff --git a/OpenSim/Framework/Data/ReservationData.cs b/OpenSim/Framework/Data/ReservationData.cs
index 1e606ee..06adf04 100644
--- a/OpenSim/Framework/Data/ReservationData.cs
+++ b/OpenSim/Framework/Data/ReservationData.cs
@@ -36,7 +36,7 @@ namespace OpenSim.Framework.Data
36 public int reservationMinY = 0; 36 public int reservationMinY = 0;
37 public int reservationMaxX = 65536; 37 public int reservationMaxX = 65536;
38 public int reservationMaxY = 65536; 38 public int reservationMaxY = 65536;
39 39
40 public string reservationName = ""; 40 public string reservationName = "";
41 public string reservationCompany = ""; 41 public string reservationCompany = "";
42 public bool status = true; 42 public bool status = true;
@@ -44,4 +44,4 @@ namespace OpenSim.Framework.Data
44 public string gridSendKey = ""; 44 public string gridSendKey = "";
45 public string gridRecvKey = ""; 45 public string gridRecvKey = "";
46 } 46 }
47} 47} \ No newline at end of file