aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenGridServices
diff options
context:
space:
mode:
Diffstat (limited to 'OpenGridServices')
-rw-r--r--OpenGridServices/OpenGrid.Framework.Data.MSSQL/MSSQLManager.cs6
-rw-r--r--OpenGridServices/OpenGrid.Framework.Data.MySQL/MySQLGridData.cs55
-rw-r--r--OpenGridServices/OpenGrid.Framework.Data.MySQL/MySQLInventoryData.cs87
-rw-r--r--OpenGridServices/OpenGrid.Framework.Data.MySQL/MySQLLogData.cs55
-rw-r--r--OpenGridServices/OpenGrid.Framework.Data.MySQL/MySQLManager.cs125
-rw-r--r--OpenGridServices/OpenGrid.Framework.Data.MySQL/MySQLUserData.cs100
6 files changed, 402 insertions, 26 deletions
diff --git a/OpenGridServices/OpenGrid.Framework.Data.MSSQL/MSSQLManager.cs b/OpenGridServices/OpenGrid.Framework.Data.MSSQL/MSSQLManager.cs
index 36d5744..85e3129 100644
--- a/OpenGridServices/OpenGrid.Framework.Data.MSSQL/MSSQLManager.cs
+++ b/OpenGridServices/OpenGrid.Framework.Data.MSSQL/MSSQLManager.cs
@@ -35,8 +35,14 @@ using OpenGrid.Framework.Data;
35 35
36namespace OpenGrid.Framework.Data.MSSQL 36namespace OpenGrid.Framework.Data.MSSQL
37{ 37{
38 /// <summary>
39 /// A management class for the MS SQL Storage Engine
40 /// </summary>
38 class MSSqlManager 41 class MSSqlManager
39 { 42 {
43 /// <summary>
44 /// The database connection object
45 /// </summary>
40 IDbConnection dbcon; 46 IDbConnection dbcon;
41 47
42 /// <summary> 48 /// <summary>
diff --git a/OpenGridServices/OpenGrid.Framework.Data.MySQL/MySQLGridData.cs b/OpenGridServices/OpenGrid.Framework.Data.MySQL/MySQLGridData.cs
index e047c6d..5c2e567 100644
--- a/OpenGridServices/OpenGrid.Framework.Data.MySQL/MySQLGridData.cs
+++ b/OpenGridServices/OpenGrid.Framework.Data.MySQL/MySQLGridData.cs
@@ -1,3 +1,29 @@
1/*
2* Copyright (c) OpenSim project, http://sim.opensecondlife.org/
3*
4* Redistribution and use in source and binary forms, with or without
5* modification, are permitted provided that the following conditions are met:
6* * Redistributions of source code must retain the above copyright
7* notice, this list of conditions and the following disclaimer.
8* * Redistributions in binary form must reproduce the above copyright
9* notice, this list of conditions and the following disclaimer in the
10* documentation and/or other materials provided with the distribution.
11* * Neither the name of the <organization> nor the
12* names of its contributors may be used to endorse or promote products
13* derived from this software without specific prior written permission.
14*
15* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
16* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
19* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25*
26*/
1using System; 27using System;
2using System.Collections.Generic; 28using System.Collections.Generic;
3using System.Text; 29using System.Text;
@@ -5,8 +31,14 @@ using OpenGrid.Framework.Data;
5 31
6namespace OpenGrid.Framework.Data.MySQL 32namespace OpenGrid.Framework.Data.MySQL
7{ 33{
34 /// <summary>
35 /// A MySQL Interface for the Grid Server
36 /// </summary>
8 public class MySQLGridData : IGridData 37 public class MySQLGridData : IGridData
9 { 38 {
39 /// <summary>
40 /// MySQL Database Manager
41 /// </summary>
10 private MySQLManager database; 42 private MySQLManager database;
11 43
12 /// <summary> 44 /// <summary>
@@ -33,16 +65,32 @@ namespace OpenGrid.Framework.Data.MySQL
33 database.Close(); 65 database.Close();
34 } 66 }
35 67
68 /// <summary>
69 /// Returns the plugin name
70 /// </summary>
71 /// <returns>Plugin name</returns>
36 public string getName() 72 public string getName()
37 { 73 {
38 return "MySql OpenGridData"; 74 return "MySql OpenGridData";
39 } 75 }
40 76
77 /// <summary>
78 /// Returns the plugin version
79 /// </summary>
80 /// <returns>Plugin version</returns>
41 public string getVersion() 81 public string getVersion()
42 { 82 {
43 return "0.1"; 83 return "0.1";
44 } 84 }
45 85
86 /// <summary>
87 /// Returns all the specified region profiles within coordates -- coordinates are inclusive
88 /// </summary>
89 /// <param name="xmin">Minimum X coordinate</param>
90 /// <param name="ymin">Minimum Y coordinate</param>
91 /// <param name="xmax">Maximum X coordinate</param>
92 /// <param name="ymax">Maximum Y coordinate</param>
93 /// <returns></returns>
46 public SimProfileData[] GetProfilesInRange(uint xmin, uint ymin, uint xmax, uint ymax) 94 public SimProfileData[] GetProfilesInRange(uint xmin, uint ymin, uint xmax, uint ymax)
47 { 95 {
48 try 96 try
@@ -145,11 +193,16 @@ namespace OpenGrid.Framework.Data.MySQL
145 } 193 }
146 } 194 }
147 195
196 /// <summary>
197 /// Adds a new profile to the database
198 /// </summary>
199 /// <param name="profile">The profile to add</param>
200 /// <returns>Successful?</returns>
148 public DataResponse AddProfile(SimProfileData profile) 201 public DataResponse AddProfile(SimProfileData profile)
149 { 202 {
150 lock (database) 203 lock (database)
151 { 204 {
152 if (database.insertRow(profile)) 205 if (database.insertRegion(profile))
153 { 206 {
154 return DataResponse.RESPONSE_OK; 207 return DataResponse.RESPONSE_OK;
155 } 208 }
diff --git a/OpenGridServices/OpenGrid.Framework.Data.MySQL/MySQLInventoryData.cs b/OpenGridServices/OpenGrid.Framework.Data.MySQL/MySQLInventoryData.cs
index 50ffbb0..9177cc3 100644
--- a/OpenGridServices/OpenGrid.Framework.Data.MySQL/MySQLInventoryData.cs
+++ b/OpenGridServices/OpenGrid.Framework.Data.MySQL/MySQLInventoryData.cs
@@ -1,3 +1,29 @@
1/*
2* Copyright (c) OpenSim project, http://sim.opensecondlife.org/
3*
4* Redistribution and use in source and binary forms, with or without
5* modification, are permitted provided that the following conditions are met:
6* * Redistributions of source code must retain the above copyright
7* notice, this list of conditions and the following disclaimer.
8* * Redistributions in binary form must reproduce the above copyright
9* notice, this list of conditions and the following disclaimer in the
10* documentation and/or other materials provided with the distribution.
11* * Neither the name of the <organization> nor the
12* names of its contributors may be used to endorse or promote products
13* derived from this software without specific prior written permission.
14*
15* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
16* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
19* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25*
26*/
1using System; 27using System;
2using System.Collections.Generic; 28using System.Collections.Generic;
3using System.Text; 29using System.Text;
@@ -5,10 +31,19 @@ using libsecondlife;
5 31
6namespace OpenGrid.Framework.Data.MySQL 32namespace OpenGrid.Framework.Data.MySQL
7{ 33{
34 /// <summary>
35 /// A MySQL interface for the inventory server
36 /// </summary>
8 class MySQLInventoryData : IInventoryData 37 class MySQLInventoryData : IInventoryData
9 { 38 {
39 /// <summary>
40 /// The database manager
41 /// </summary>
10 public MySQLManager database; 42 public MySQLManager database;
11 43
44 /// <summary>
45 /// Loads and initialises this database plugin
46 /// </summary>
12 public void Initialise() 47 public void Initialise()
13 { 48 {
14 IniFile GridDataMySqlFile = new IniFile("mysql_connection.ini"); 49 IniFile GridDataMySqlFile = new IniFile("mysql_connection.ini");
@@ -22,21 +57,37 @@ namespace OpenGrid.Framework.Data.MySQL
22 database = new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling, settingPort); 57 database = new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling, settingPort);
23 } 58 }
24 59
60 /// <summary>
61 /// The name of this DB provider
62 /// </summary>
63 /// <returns>Name of DB provider</returns>
25 public string getName() 64 public string getName()
26 { 65 {
27 return "MySQL Inventory Data Interface"; 66 return "MySQL Inventory Data Interface";
28 } 67 }
29 68
69 /// <summary>
70 /// Closes this DB provider
71 /// </summary>
30 public void Close() 72 public void Close()
31 { 73 {
32 // Do nothing. 74 // Do nothing.
33 } 75 }
34 76
77 /// <summary>
78 /// Returns the version of this DB provider
79 /// </summary>
80 /// <returns>A string containing the DB provider</returns>
35 public string getVersion() 81 public string getVersion()
36 { 82 {
37 return "0.1"; 83 return "0.1";
38 } 84 }
39 85
86 /// <summary>
87 /// Returns a list of items in a specified folder
88 /// </summary>
89 /// <param name="folderID">The folder to search</param>
90 /// <returns>A list containing inventory items</returns>
40 public List<InventoryItemBase> getInventoryInFolder(LLUUID folderID) 91 public List<InventoryItemBase> getInventoryInFolder(LLUUID folderID)
41 { 92 {
42 try 93 try
@@ -65,6 +116,11 @@ namespace OpenGrid.Framework.Data.MySQL
65 } 116 }
66 } 117 }
67 118
119 /// <summary>
120 /// Returns a list of the root folders within a users inventory
121 /// </summary>
122 /// <param name="user">The user whos inventory is to be searched</param>
123 /// <returns>A list of folder objects</returns>
68 public List<InventoryFolderBase> getUserRootFolders(LLUUID user) 124 public List<InventoryFolderBase> getUserRootFolders(LLUUID user)
69 { 125 {
70 try 126 try
@@ -94,6 +150,11 @@ namespace OpenGrid.Framework.Data.MySQL
94 } 150 }
95 } 151 }
96 152
153 /// <summary>
154 /// Returns a list of folders in a users inventory contained within the specified folder
155 /// </summary>
156 /// <param name="parentID">The folder to search</param>
157 /// <returns>A list of inventory folders</returns>
97 public List<InventoryFolderBase> getInventoryFolders(LLUUID parentID) 158 public List<InventoryFolderBase> getInventoryFolders(LLUUID parentID)
98 { 159 {
99 try 160 try
@@ -122,6 +183,11 @@ namespace OpenGrid.Framework.Data.MySQL
122 } 183 }
123 } 184 }
124 185
186 /// <summary>
187 /// Returns a specified inventory item
188 /// </summary>
189 /// <param name="item">The item to return</param>
190 /// <returns>An inventory item</returns>
125 public InventoryItemBase getInventoryItem(LLUUID item) 191 public InventoryItemBase getInventoryItem(LLUUID item)
126 { 192 {
127 try 193 try
@@ -157,6 +223,11 @@ namespace OpenGrid.Framework.Data.MySQL
157 } 223 }
158 } 224 }
159 225
226 /// <summary>
227 /// Returns a specified inventory folder
228 /// </summary>
229 /// <param name="folder">The folder to return</param>
230 /// <returns>A folder class</returns>
160 public InventoryFolderBase getInventoryFolder(LLUUID folder) 231 public InventoryFolderBase getInventoryFolder(LLUUID folder)
161 { 232 {
162 try 233 try
@@ -192,6 +263,10 @@ namespace OpenGrid.Framework.Data.MySQL
192 } 263 }
193 } 264 }
194 265
266 /// <summary>
267 /// Adds a specified item to the database
268 /// </summary>
269 /// <param name="item">The inventory item</param>
195 public void addInventoryItem(InventoryItemBase item) 270 public void addInventoryItem(InventoryItemBase item)
196 { 271 {
197 lock (database) 272 lock (database)
@@ -200,11 +275,19 @@ namespace OpenGrid.Framework.Data.MySQL
200 } 275 }
201 } 276 }
202 277
278 /// <summary>
279 /// Updates the specified inventory item
280 /// </summary>
281 /// <param name="item">Inventory item to update</param>
203 public void updateInventoryItem(InventoryItemBase item) 282 public void updateInventoryItem(InventoryItemBase item)
204 { 283 {
205 addInventoryItem(item); 284 addInventoryItem(item);
206 } 285 }
207 286
287 /// <summary>
288 /// Creates a new inventory folder
289 /// </summary>
290 /// <param name="folder">Folder to create</param>
208 public void addInventoryFolder(InventoryFolderBase folder) 291 public void addInventoryFolder(InventoryFolderBase folder)
209 { 292 {
210 lock (database) 293 lock (database)
@@ -213,6 +296,10 @@ namespace OpenGrid.Framework.Data.MySQL
213 } 296 }
214 } 297 }
215 298
299 /// <summary>
300 /// Updates an inventory folder
301 /// </summary>
302 /// <param name="folder">Folder to update</param>
216 public void updateInventoryFolder(InventoryFolderBase folder) 303 public void updateInventoryFolder(InventoryFolderBase folder)
217 { 304 {
218 addInventoryFolder(folder); 305 addInventoryFolder(folder);
diff --git a/OpenGridServices/OpenGrid.Framework.Data.MySQL/MySQLLogData.cs b/OpenGridServices/OpenGrid.Framework.Data.MySQL/MySQLLogData.cs
index c2f9653..3765ae1 100644
--- a/OpenGridServices/OpenGrid.Framework.Data.MySQL/MySQLLogData.cs
+++ b/OpenGridServices/OpenGrid.Framework.Data.MySQL/MySQLLogData.cs
@@ -1,13 +1,48 @@
1/*
2* Copyright (c) OpenSim project, http://sim.opensecondlife.org/
3*
4* Redistribution and use in source and binary forms, with or without
5* modification, are permitted provided that the following conditions are met:
6* * Redistributions of source code must retain the above copyright
7* notice, this list of conditions and the following disclaimer.
8* * Redistributions in binary form must reproduce the above copyright
9* notice, this list of conditions and the following disclaimer in the
10* documentation and/or other materials provided with the distribution.
11* * Neither the name of the <organization> nor the
12* names of its contributors may be used to endorse or promote products
13* derived from this software without specific prior written permission.
14*
15* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
16* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
19* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25*
26*/
1using System; 27using System;
2using System.Collections.Generic; 28using System.Collections.Generic;
3using System.Text; 29using System.Text;
4 30
5namespace OpenGrid.Framework.Data.MySQL 31namespace OpenGrid.Framework.Data.MySQL
6{ 32{
33 /// <summary>
34 /// An interface to the log database for MySQL
35 /// </summary>
7 class MySQLLogData : ILogData 36 class MySQLLogData : ILogData
8 { 37 {
38 /// <summary>
39 /// The database manager
40 /// </summary>
9 public MySQLManager database; 41 public MySQLManager database;
10 42
43 /// <summary>
44 /// Artificial constructor called when the plugin is loaded
45 /// </summary>
11 public void Initialise() 46 public void Initialise()
12 { 47 {
13 IniFile GridDataMySqlFile = new IniFile("mysql_connection.ini"); 48 IniFile GridDataMySqlFile = new IniFile("mysql_connection.ini");
@@ -21,6 +56,15 @@ namespace OpenGrid.Framework.Data.MySQL
21 database = new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling, settingPort); 56 database = new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling, settingPort);
22 } 57 }
23 58
59 /// <summary>
60 /// Saves a log item to the database
61 /// </summary>
62 /// <param name="serverDaemon">The daemon triggering the event</param>
63 /// <param name="target">The target of the action (region / agent UUID, etc)</param>
64 /// <param name="methodCall">The method call where the problem occured</param>
65 /// <param name="arguments">The arguments passed to the method</param>
66 /// <param name="priority">How critical is this?</param>
67 /// <param name="logMessage">The message to log</param>
24 public void saveLog(string serverDaemon, string target, string methodCall, string arguments, int priority, string logMessage) 68 public void saveLog(string serverDaemon, string target, string methodCall, string arguments, int priority, string logMessage)
25 { 69 {
26 try 70 try
@@ -33,16 +77,27 @@ namespace OpenGrid.Framework.Data.MySQL
33 } 77 }
34 } 78 }
35 79
80 /// <summary>
81 /// Returns the name of this DB provider
82 /// </summary>
83 /// <returns>A string containing the DB provider name</returns>
36 public string getName() 84 public string getName()
37 { 85 {
38 return "MySQL Logdata Interface"; 86 return "MySQL Logdata Interface";
39 } 87 }
40 88
89 /// <summary>
90 /// Closes the database provider
91 /// </summary>
41 public void Close() 92 public void Close()
42 { 93 {
43 // Do nothing. 94 // Do nothing.
44 } 95 }
45 96
97 /// <summary>
98 /// Returns the version of this DB provider
99 /// </summary>
100 /// <returns>A string containing the provider version</returns>
46 public string getVersion() 101 public string getVersion()
47 { 102 {
48 return "0.1"; 103 return "0.1";
diff --git a/OpenGridServices/OpenGrid.Framework.Data.MySQL/MySQLManager.cs b/OpenGridServices/OpenGrid.Framework.Data.MySQL/MySQLManager.cs
index 9fbdffb..6ddd02c 100644
--- a/OpenGridServices/OpenGrid.Framework.Data.MySQL/MySQLManager.cs
+++ b/OpenGridServices/OpenGrid.Framework.Data.MySQL/MySQLManager.cs
@@ -1,3 +1,29 @@
1/*
2* Copyright (c) OpenSim project, http://sim.opensecondlife.org/
3*
4* Redistribution and use in source and binary forms, with or without
5* modification, are permitted provided that the following conditions are met:
6* * Redistributions of source code must retain the above copyright
7* notice, this list of conditions and the following disclaimer.
8* * Redistributions in binary form must reproduce the above copyright
9* notice, this list of conditions and the following disclaimer in the
10* documentation and/or other materials provided with the distribution.
11* * Neither the name of the <organization> nor the
12* names of its contributors may be used to endorse or promote products
13* derived from this software without specific prior written permission.
14*
15* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
16* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
19* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25*
26*/
1using System; 27using System;
2using System.Collections.Generic; 28using System.Collections.Generic;
3using System.Text; 29using System.Text;
@@ -13,9 +39,18 @@ using OpenGrid.Framework.Data;
13 39
14namespace OpenGrid.Framework.Data.MySQL 40namespace OpenGrid.Framework.Data.MySQL
15{ 41{
42 /// <summary>
43 /// A MySQL Database manager
44 /// </summary>
16 class MySQLManager 45 class MySQLManager
17 { 46 {
47 /// <summary>
48 /// The database connection object
49 /// </summary>
18 IDbConnection dbcon; 50 IDbConnection dbcon;
51 /// <summary>
52 /// Connection string for ADO.net
53 /// </summary>
19 string connectionString; 54 string connectionString;
20 55
21 /// <summary> 56 /// <summary>
@@ -137,6 +172,11 @@ namespace OpenGrid.Framework.Data.MySQL
137 } 172 }
138 } 173 }
139 174
175 /// <summary>
176 /// Reads a region row from a database reader
177 /// </summary>
178 /// <param name="reader">An active database reader</param>
179 /// <returns>A region profile</returns>
140 public SimProfileData readSimRow(IDataReader reader) 180 public SimProfileData readSimRow(IDataReader reader)
141 { 181 {
142 SimProfileData retval = new SimProfileData(); 182 SimProfileData retval = new SimProfileData();
@@ -199,6 +239,11 @@ namespace OpenGrid.Framework.Data.MySQL
199 return retval; 239 return retval;
200 } 240 }
201 241
242 /// <summary>
243 /// Reads an agent row from a database reader
244 /// </summary>
245 /// <param name="reader">An active database reader</param>
246 /// <returns>A user session agent</returns>
202 public UserAgentData readAgentRow(IDataReader reader) 247 public UserAgentData readAgentRow(IDataReader reader)
203 { 248 {
204 UserAgentData retval = new UserAgentData(); 249 UserAgentData retval = new UserAgentData();
@@ -231,6 +276,11 @@ namespace OpenGrid.Framework.Data.MySQL
231 return retval; 276 return retval;
232 } 277 }
233 278
279 /// <summary>
280 /// Reads a user profile from an active data reader
281 /// </summary>
282 /// <param name="reader">An active database reader</param>
283 /// <returns>A user profile</returns>
234 public UserProfileData readUserRow(IDataReader reader) 284 public UserProfileData readUserRow(IDataReader reader)
235 { 285 {
236 UserProfileData retval = new UserProfileData(); 286 UserProfileData retval = new UserProfileData();
@@ -344,6 +394,16 @@ namespace OpenGrid.Framework.Data.MySQL
344 return rows; 394 return rows;
345 } 395 }
346 396
397 /// <summary>
398 /// Inserts a new row into the log database
399 /// </summary>
400 /// <param name="serverDaemon">The daemon which triggered this event</param>
401 /// <param name="target">Who were we operating on when this occured (region UUID, user UUID, etc)</param>
402 /// <param name="methodCall">The method call where the problem occured</param>
403 /// <param name="arguments">The arguments passed to the method</param>
404 /// <param name="priority">How critical is this?</param>
405 /// <param name="logMessage">Extra message info</param>
406 /// <returns>Saved successfully?</returns>
347 public bool insertLogRow(string serverDaemon, string target, string methodCall, string arguments, int priority, string logMessage) 407 public bool insertLogRow(string serverDaemon, string target, string methodCall, string arguments, int priority, string logMessage)
348 { 408 {
349 string sql = "INSERT INTO logs (`target`, `server`, `method`, `arguments`, `priority`, `message`) VALUES "; 409 string sql = "INSERT INTO logs (`target`, `server`, `method`, `arguments`, `priority`, `message`) VALUES ";
@@ -377,6 +437,11 @@ namespace OpenGrid.Framework.Data.MySQL
377 return returnval; 437 return returnval;
378 } 438 }
379 439
440 /// <summary>
441 /// Inserts a new item into the database
442 /// </summary>
443 /// <param name="item">The item</param>
444 /// <returns>Success?</returns>
380 public bool insertItem(InventoryItemBase item) 445 public bool insertItem(InventoryItemBase item)
381 { 446 {
382 string sql = "REPLACE INTO inventoryitems (inventoryID, assetID, type, parentFolderID, avatarID, inventoryName, inventoryDescription, inventoryNextPermissions, inventoryCurrentPermissions) VALUES "; 447 string sql = "REPLACE INTO inventoryitems (inventoryID, assetID, type, parentFolderID, avatarID, inventoryName, inventoryDescription, inventoryNextPermissions, inventoryCurrentPermissions) VALUES ";
@@ -413,6 +478,11 @@ namespace OpenGrid.Framework.Data.MySQL
413 return returnval; 478 return returnval;
414 } 479 }
415 480
481 /// <summary>
482 /// Inserts a new folder into the database
483 /// </summary>
484 /// <param name="folder">The folder</param>
485 /// <returns>Success?</returns>
416 public bool insertFolder(InventoryFolderBase folder) 486 public bool insertFolder(InventoryFolderBase folder)
417 { 487 {
418 string sql = "REPLACE INTO inventoryfolders (folderID, agentID, parentFolderID, folderName) VALUES "; 488 string sql = "REPLACE INTO inventoryfolders (folderID, agentID, parentFolderID, folderName) VALUES ";
@@ -442,7 +512,12 @@ namespace OpenGrid.Framework.Data.MySQL
442 return returnval; 512 return returnval;
443 } 513 }
444 514
445 public bool insertRow(SimProfileData profile) 515 /// <summary>
516 /// Inserts a new region into the database
517 /// </summary>
518 /// <param name="profile">The region to insert</param>
519 /// <returns>Success?</returns>
520 public bool insertRegion(SimProfileData regiondata)
446 { 521 {
447 string sql = "REPLACE INTO regions (regionHandle, regionName, uuid, regionRecvKey, regionSecret, regionSendKey, regionDataURI, "; 522 string sql = "REPLACE INTO regions (regionHandle, regionName, uuid, regionRecvKey, regionSecret, regionSendKey, regionDataURI, ";
448 sql += "serverIP, serverPort, serverURI, locX, locY, locZ, eastOverrideHandle, westOverrideHandle, southOverrideHandle, northOverrideHandle, regionAssetURI, regionAssetRecvKey, "; 523 sql += "serverIP, serverPort, serverURI, locX, locY, locZ, eastOverrideHandle, westOverrideHandle, southOverrideHandle, northOverrideHandle, regionAssetURI, regionAssetRecvKey, ";
@@ -454,30 +529,30 @@ namespace OpenGrid.Framework.Data.MySQL
454 529
455 Dictionary<string, string> parameters = new Dictionary<string, string>(); 530 Dictionary<string, string> parameters = new Dictionary<string, string>();
456 531
457 parameters["?regionHandle"] = profile.regionHandle.ToString(); 532 parameters["?regionHandle"] = regiondata.regionHandle.ToString();
458 parameters["?regionName"] = profile.regionName.ToString(); 533 parameters["?regionName"] = regiondata.regionName.ToString();
459 parameters["?uuid"] = profile.UUID.ToStringHyphenated(); 534 parameters["?uuid"] = regiondata.UUID.ToStringHyphenated();
460 parameters["?regionRecvKey"] = profile.regionRecvKey.ToString(); 535 parameters["?regionRecvKey"] = regiondata.regionRecvKey.ToString();
461 parameters["?regionSecret"] = profile.regionSecret.ToString(); 536 parameters["?regionSecret"] = regiondata.regionSecret.ToString();
462 parameters["?regionSendKey"] = profile.regionSendKey.ToString(); 537 parameters["?regionSendKey"] = regiondata.regionSendKey.ToString();
463 parameters["?regionDataURI"] = profile.regionDataURI.ToString(); 538 parameters["?regionDataURI"] = regiondata.regionDataURI.ToString();
464 parameters["?serverIP"] = profile.serverIP.ToString(); 539 parameters["?serverIP"] = regiondata.serverIP.ToString();
465 parameters["?serverPort"] = profile.serverPort.ToString(); 540 parameters["?serverPort"] = regiondata.serverPort.ToString();
466 parameters["?serverURI"] = profile.serverURI.ToString(); 541 parameters["?serverURI"] = regiondata.serverURI.ToString();
467 parameters["?locX"] = profile.regionLocX.ToString(); 542 parameters["?locX"] = regiondata.regionLocX.ToString();
468 parameters["?locY"] = profile.regionLocY.ToString(); 543 parameters["?locY"] = regiondata.regionLocY.ToString();
469 parameters["?locZ"] = profile.regionLocZ.ToString(); 544 parameters["?locZ"] = regiondata.regionLocZ.ToString();
470 parameters["?eastOverrideHandle"] = profile.regionEastOverrideHandle.ToString(); 545 parameters["?eastOverrideHandle"] = regiondata.regionEastOverrideHandle.ToString();
471 parameters["?westOverrideHandle"] = profile.regionWestOverrideHandle.ToString(); 546 parameters["?westOverrideHandle"] = regiondata.regionWestOverrideHandle.ToString();
472 parameters["?northOverrideHandle"] = profile.regionNorthOverrideHandle.ToString(); 547 parameters["?northOverrideHandle"] = regiondata.regionNorthOverrideHandle.ToString();
473 parameters["?southOverrideHandle"] = profile.regionSouthOverrideHandle.ToString(); 548 parameters["?southOverrideHandle"] = regiondata.regionSouthOverrideHandle.ToString();
474 parameters["?regionAssetURI"] = profile.regionAssetURI.ToString(); 549 parameters["?regionAssetURI"] = regiondata.regionAssetURI.ToString();
475 parameters["?regionAssetRecvKey"] = profile.regionAssetRecvKey.ToString(); 550 parameters["?regionAssetRecvKey"] = regiondata.regionAssetRecvKey.ToString();
476 parameters["?regionAssetSendKey"] = profile.regionAssetSendKey.ToString(); 551 parameters["?regionAssetSendKey"] = regiondata.regionAssetSendKey.ToString();
477 parameters["?regionUserURI"] = profile.regionUserURI.ToString(); 552 parameters["?regionUserURI"] = regiondata.regionUserURI.ToString();
478 parameters["?regionUserRecvKey"] = profile.regionUserRecvKey.ToString(); 553 parameters["?regionUserRecvKey"] = regiondata.regionUserRecvKey.ToString();
479 parameters["?regionUserSendKey"] = profile.regionUserSendKey.ToString(); 554 parameters["?regionUserSendKey"] = regiondata.regionUserSendKey.ToString();
480 parameters["?regionMapTexture"] = profile.regionMapTextureID.ToStringHyphenated(); 555 parameters["?regionMapTexture"] = regiondata.regionMapTextureID.ToStringHyphenated();
481 556
482 bool returnval = false; 557 bool returnval = false;
483 558
diff --git a/OpenGridServices/OpenGrid.Framework.Data.MySQL/MySQLUserData.cs b/OpenGridServices/OpenGrid.Framework.Data.MySQL/MySQLUserData.cs
index 4a7276c..1bb9125 100644
--- a/OpenGridServices/OpenGrid.Framework.Data.MySQL/MySQLUserData.cs
+++ b/OpenGridServices/OpenGrid.Framework.Data.MySQL/MySQLUserData.cs
@@ -1,3 +1,29 @@
1/*
2* Copyright (c) OpenSim project, http://sim.opensecondlife.org/
3*
4* Redistribution and use in source and binary forms, with or without
5* modification, are permitted provided that the following conditions are met:
6* * Redistributions of source code must retain the above copyright
7* notice, this list of conditions and the following disclaimer.
8* * Redistributions in binary form must reproduce the above copyright
9* notice, this list of conditions and the following disclaimer in the
10* documentation and/or other materials provided with the distribution.
11* * Neither the name of the <organization> nor the
12* names of its contributors may be used to endorse or promote products
13* derived from this software without specific prior written permission.
14*
15* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
16* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
19* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25*
26*/
1using System; 27using System;
2using System.Collections.Generic; 28using System.Collections.Generic;
3using System.Text; 29using System.Text;
@@ -6,12 +32,23 @@ using libsecondlife;
6 32
7namespace OpenGrid.Framework.Data.MySQL 33namespace OpenGrid.Framework.Data.MySQL
8{ 34{
35 /// <summary>
36 /// A database interface class to a user profile storage system
37 /// </summary>
9 class MySQLUserData : IUserData 38 class MySQLUserData : IUserData
10 { 39 {
40 /// <summary>
41 /// Database manager for MySQL
42 /// </summary>
11 public MySQLManager database; 43 public MySQLManager database;
12 44
45 /// <summary>
46 /// Loads and initialises the MySQL storage plugin
47 /// </summary>
13 public void Initialise() 48 public void Initialise()
14 { 49 {
50 // Load from an INI file connection details
51 // TODO: move this to XML?
15 IniFile GridDataMySqlFile = new IniFile("mysql_connection.ini"); 52 IniFile GridDataMySqlFile = new IniFile("mysql_connection.ini");
16 string settingHostname = GridDataMySqlFile.ParseFileReadValue("hostname"); 53 string settingHostname = GridDataMySqlFile.ParseFileReadValue("hostname");
17 string settingDatabase = GridDataMySqlFile.ParseFileReadValue("database"); 54 string settingDatabase = GridDataMySqlFile.ParseFileReadValue("database");
@@ -23,11 +60,22 @@ namespace OpenGrid.Framework.Data.MySQL
23 database = new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling, settingPort); 60 database = new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling, settingPort);
24 } 61 }
25 62
63 /// <summary>
64 /// Searches the database for a specified user profile
65 /// </summary>
66 /// <param name="name">The account name of the user</param>
67 /// <returns>A user profile</returns>
26 public UserProfileData getUserByName(string name) 68 public UserProfileData getUserByName(string name)
27 { 69 {
28 return getUserByName(name.Split(' ')[0], name.Split(' ')[1]); 70 return getUserByName(name.Split(' ')[0], name.Split(' ')[1]);
29 } 71 }
30 72
73 /// <summary>
74 /// Searches the database for a specified user profile by name components
75 /// </summary>
76 /// <param name="user">The first part of the account name</param>
77 /// <param name="last">The second part of the account name</param>
78 /// <returns>A user profile</returns>
31 public UserProfileData getUserByName(string user, string last) 79 public UserProfileData getUserByName(string user, string last)
32 { 80 {
33 try 81 try
@@ -57,6 +105,11 @@ namespace OpenGrid.Framework.Data.MySQL
57 } 105 }
58 } 106 }
59 107
108 /// <summary>
109 /// Searches the database for a specified user profile by UUID
110 /// </summary>
111 /// <param name="uuid">The account ID</param>
112 /// <returns>The users profile</returns>
60 public UserProfileData getUserByUUID(LLUUID uuid) 113 public UserProfileData getUserByUUID(LLUUID uuid)
61 { 114 {
62 try 115 try
@@ -85,17 +138,33 @@ namespace OpenGrid.Framework.Data.MySQL
85 } 138 }
86 } 139 }
87 140
141 /// <summary>
142 /// Returns a user session searching by name
143 /// </summary>
144 /// <param name="name">The account name</param>
145 /// <returns>The users session</returns>
88 public UserAgentData getAgentByName(string name) 146 public UserAgentData getAgentByName(string name)
89 { 147 {
90 return getAgentByName(name.Split(' ')[0], name.Split(' ')[1]); 148 return getAgentByName(name.Split(' ')[0], name.Split(' ')[1]);
91 } 149 }
92 150
151 /// <summary>
152 /// Returns a user session by account name
153 /// </summary>
154 /// <param name="user">First part of the users account name</param>
155 /// <param name="last">Second part of the users account name</param>
156 /// <returns>The users session</returns>
93 public UserAgentData getAgentByName(string user, string last) 157 public UserAgentData getAgentByName(string user, string last)
94 { 158 {
95 UserProfileData profile = getUserByName(user, last); 159 UserProfileData profile = getUserByName(user, last);
96 return getAgentByUUID(profile.UUID); 160 return getAgentByUUID(profile.UUID);
97 } 161 }
98 162
163 /// <summary>
164 /// Returns an agent session by account UUID
165 /// </summary>
166 /// <param name="uuid">The accounts UUID</param>
167 /// <returns>The users session</returns>
99 public UserAgentData getAgentByUUID(LLUUID uuid) 168 public UserAgentData getAgentByUUID(LLUUID uuid)
100 { 169 {
101 try 170 try
@@ -124,30 +193,61 @@ namespace OpenGrid.Framework.Data.MySQL
124 } 193 }
125 } 194 }
126 195
196 /// <summary>
197 /// Creates a new users profile
198 /// </summary>
199 /// <param name="user">The user profile to create</param>
127 public void addNewUserProfile(UserProfileData user) 200 public void addNewUserProfile(UserProfileData user)
128 { 201 {
129 } 202 }
130 203
204 /// <summary>
205 /// Creates a new agent
206 /// </summary>
207 /// <param name="agent">The agent to create</param>
131 public void addNewUserAgent(UserAgentData agent) 208 public void addNewUserAgent(UserAgentData agent)
132 { 209 {
133 // Do nothing. 210 // Do nothing.
134 } 211 }
135 212
213 /// <summary>
214 /// Performs a money transfer request between two accounts
215 /// </summary>
216 /// <param name="from">The senders account ID</param>
217 /// <param name="to">The recievers account ID</param>
218 /// <param name="amount">The amount to transfer</param>
219 /// <returns>Success?</returns>
136 public bool moneyTransferRequest(LLUUID from, LLUUID to, uint amount) 220 public bool moneyTransferRequest(LLUUID from, LLUUID to, uint amount)
137 { 221 {
138 return false; 222 return false;
139 } 223 }
140 224
225 /// <summary>
226 /// Performs an inventory transfer request between two accounts
227 /// </summary>
228 /// <remarks>TODO: Move to inventory server</remarks>
229 /// <param name="from">The senders account ID</param>
230 /// <param name="to">The recievers account ID</param>
231 /// <param name="item">The item to transfer</param>
232 /// <returns>Success?</returns>
141 public bool inventoryTransferRequest(LLUUID from, LLUUID to, LLUUID item) 233 public bool inventoryTransferRequest(LLUUID from, LLUUID to, LLUUID item)
142 { 234 {
143 return false; 235 return false;
144 } 236 }
145 237
238 /// <summary>
239 /// Database provider name
240 /// </summary>
241 /// <returns>Provider name</returns>
146 public string getName() 242 public string getName()
147 { 243 {
148 return "MySQL Userdata Interface"; 244 return "MySQL Userdata Interface";
149 } 245 }
150 246
247 /// <summary>
248 /// Database provider version
249 /// </summary>
250 /// <returns>provider version</returns>
151 public string getVersion() 251 public string getVersion()
152 { 252 {
153 return "0.1"; 253 return "0.1";