Dont want to do that again --- MySQL interface is now fully documented. Added little bit more documentation to the MSSQL interface.
parent
14babaaece
commit
55f7fe0ae3
|
@ -35,8 +35,14 @@ using OpenGrid.Framework.Data;
|
||||||
|
|
||||||
namespace OpenGrid.Framework.Data.MSSQL
|
namespace OpenGrid.Framework.Data.MSSQL
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// A management class for the MS SQL Storage Engine
|
||||||
|
/// </summary>
|
||||||
class MSSqlManager
|
class MSSqlManager
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The database connection object
|
||||||
|
/// </summary>
|
||||||
IDbConnection dbcon;
|
IDbConnection dbcon;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -1,3 +1,29 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) OpenSim project, http://sim.opensecondlife.org/
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of the <organization> nor the
|
||||||
|
* names of its contributors may be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
|
||||||
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
*/
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
@ -5,8 +31,14 @@ using OpenGrid.Framework.Data;
|
||||||
|
|
||||||
namespace OpenGrid.Framework.Data.MySQL
|
namespace OpenGrid.Framework.Data.MySQL
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// A MySQL Interface for the Grid Server
|
||||||
|
/// </summary>
|
||||||
public class MySQLGridData : IGridData
|
public class MySQLGridData : IGridData
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// MySQL Database Manager
|
||||||
|
/// </summary>
|
||||||
private MySQLManager database;
|
private MySQLManager database;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -33,16 +65,32 @@ namespace OpenGrid.Framework.Data.MySQL
|
||||||
database.Close();
|
database.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the plugin name
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>Plugin name</returns>
|
||||||
public string getName()
|
public string getName()
|
||||||
{
|
{
|
||||||
return "MySql OpenGridData";
|
return "MySql OpenGridData";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the plugin version
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>Plugin version</returns>
|
||||||
public string getVersion()
|
public string getVersion()
|
||||||
{
|
{
|
||||||
return "0.1";
|
return "0.1";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns all the specified region profiles within coordates -- coordinates are inclusive
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="xmin">Minimum X coordinate</param>
|
||||||
|
/// <param name="ymin">Minimum Y coordinate</param>
|
||||||
|
/// <param name="xmax">Maximum X coordinate</param>
|
||||||
|
/// <param name="ymax">Maximum Y coordinate</param>
|
||||||
|
/// <returns></returns>
|
||||||
public SimProfileData[] GetProfilesInRange(uint xmin, uint ymin, uint xmax, uint ymax)
|
public SimProfileData[] GetProfilesInRange(uint xmin, uint ymin, uint xmax, uint ymax)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -145,11 +193,16 @@ namespace OpenGrid.Framework.Data.MySQL
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Adds a new profile to the database
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="profile">The profile to add</param>
|
||||||
|
/// <returns>Successful?</returns>
|
||||||
public DataResponse AddProfile(SimProfileData profile)
|
public DataResponse AddProfile(SimProfileData profile)
|
||||||
{
|
{
|
||||||
lock (database)
|
lock (database)
|
||||||
{
|
{
|
||||||
if (database.insertRow(profile))
|
if (database.insertRegion(profile))
|
||||||
{
|
{
|
||||||
return DataResponse.RESPONSE_OK;
|
return DataResponse.RESPONSE_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,29 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) OpenSim project, http://sim.opensecondlife.org/
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of the <organization> nor the
|
||||||
|
* names of its contributors may be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
|
||||||
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
*/
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
@ -5,10 +31,19 @@ using libsecondlife;
|
||||||
|
|
||||||
namespace OpenGrid.Framework.Data.MySQL
|
namespace OpenGrid.Framework.Data.MySQL
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// A MySQL interface for the inventory server
|
||||||
|
/// </summary>
|
||||||
class MySQLInventoryData : IInventoryData
|
class MySQLInventoryData : IInventoryData
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The database manager
|
||||||
|
/// </summary>
|
||||||
public MySQLManager database;
|
public MySQLManager database;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Loads and initialises this database plugin
|
||||||
|
/// </summary>
|
||||||
public void Initialise()
|
public void Initialise()
|
||||||
{
|
{
|
||||||
IniFile GridDataMySqlFile = new IniFile("mysql_connection.ini");
|
IniFile GridDataMySqlFile = new IniFile("mysql_connection.ini");
|
||||||
|
@ -22,21 +57,37 @@ namespace OpenGrid.Framework.Data.MySQL
|
||||||
database = new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling, settingPort);
|
database = new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling, settingPort);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The name of this DB provider
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>Name of DB provider</returns>
|
||||||
public string getName()
|
public string getName()
|
||||||
{
|
{
|
||||||
return "MySQL Inventory Data Interface";
|
return "MySQL Inventory Data Interface";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Closes this DB provider
|
||||||
|
/// </summary>
|
||||||
public void Close()
|
public void Close()
|
||||||
{
|
{
|
||||||
// Do nothing.
|
// Do nothing.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the version of this DB provider
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>A string containing the DB provider</returns>
|
||||||
public string getVersion()
|
public string getVersion()
|
||||||
{
|
{
|
||||||
return "0.1";
|
return "0.1";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns a list of items in a specified folder
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="folderID">The folder to search</param>
|
||||||
|
/// <returns>A list containing inventory items</returns>
|
||||||
public List<InventoryItemBase> getInventoryInFolder(LLUUID folderID)
|
public List<InventoryItemBase> getInventoryInFolder(LLUUID folderID)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -65,6 +116,11 @@ namespace OpenGrid.Framework.Data.MySQL
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns a list of the root folders within a users inventory
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="user">The user whos inventory is to be searched</param>
|
||||||
|
/// <returns>A list of folder objects</returns>
|
||||||
public List<InventoryFolderBase> getUserRootFolders(LLUUID user)
|
public List<InventoryFolderBase> getUserRootFolders(LLUUID user)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -94,6 +150,11 @@ namespace OpenGrid.Framework.Data.MySQL
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns a list of folders in a users inventory contained within the specified folder
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="parentID">The folder to search</param>
|
||||||
|
/// <returns>A list of inventory folders</returns>
|
||||||
public List<InventoryFolderBase> getInventoryFolders(LLUUID parentID)
|
public List<InventoryFolderBase> getInventoryFolders(LLUUID parentID)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -122,6 +183,11 @@ namespace OpenGrid.Framework.Data.MySQL
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns a specified inventory item
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="item">The item to return</param>
|
||||||
|
/// <returns>An inventory item</returns>
|
||||||
public InventoryItemBase getInventoryItem(LLUUID item)
|
public InventoryItemBase getInventoryItem(LLUUID item)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -157,6 +223,11 @@ namespace OpenGrid.Framework.Data.MySQL
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns a specified inventory folder
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="folder">The folder to return</param>
|
||||||
|
/// <returns>A folder class</returns>
|
||||||
public InventoryFolderBase getInventoryFolder(LLUUID folder)
|
public InventoryFolderBase getInventoryFolder(LLUUID folder)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -192,6 +263,10 @@ namespace OpenGrid.Framework.Data.MySQL
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Adds a specified item to the database
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="item">The inventory item</param>
|
||||||
public void addInventoryItem(InventoryItemBase item)
|
public void addInventoryItem(InventoryItemBase item)
|
||||||
{
|
{
|
||||||
lock (database)
|
lock (database)
|
||||||
|
@ -200,11 +275,19 @@ namespace OpenGrid.Framework.Data.MySQL
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Updates the specified inventory item
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="item">Inventory item to update</param>
|
||||||
public void updateInventoryItem(InventoryItemBase item)
|
public void updateInventoryItem(InventoryItemBase item)
|
||||||
{
|
{
|
||||||
addInventoryItem(item);
|
addInventoryItem(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a new inventory folder
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="folder">Folder to create</param>
|
||||||
public void addInventoryFolder(InventoryFolderBase folder)
|
public void addInventoryFolder(InventoryFolderBase folder)
|
||||||
{
|
{
|
||||||
lock (database)
|
lock (database)
|
||||||
|
@ -213,6 +296,10 @@ namespace OpenGrid.Framework.Data.MySQL
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Updates an inventory folder
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="folder">Folder to update</param>
|
||||||
public void updateInventoryFolder(InventoryFolderBase folder)
|
public void updateInventoryFolder(InventoryFolderBase folder)
|
||||||
{
|
{
|
||||||
addInventoryFolder(folder);
|
addInventoryFolder(folder);
|
||||||
|
|
|
@ -1,13 +1,48 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) OpenSim project, http://sim.opensecondlife.org/
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of the <organization> nor the
|
||||||
|
* names of its contributors may be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
|
||||||
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
*/
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace OpenGrid.Framework.Data.MySQL
|
namespace OpenGrid.Framework.Data.MySQL
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// An interface to the log database for MySQL
|
||||||
|
/// </summary>
|
||||||
class MySQLLogData : ILogData
|
class MySQLLogData : ILogData
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The database manager
|
||||||
|
/// </summary>
|
||||||
public MySQLManager database;
|
public MySQLManager database;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Artificial constructor called when the plugin is loaded
|
||||||
|
/// </summary>
|
||||||
public void Initialise()
|
public void Initialise()
|
||||||
{
|
{
|
||||||
IniFile GridDataMySqlFile = new IniFile("mysql_connection.ini");
|
IniFile GridDataMySqlFile = new IniFile("mysql_connection.ini");
|
||||||
|
@ -21,6 +56,15 @@ namespace OpenGrid.Framework.Data.MySQL
|
||||||
database = new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling, settingPort);
|
database = new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling, settingPort);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Saves a log item to the database
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="serverDaemon">The daemon triggering the event</param>
|
||||||
|
/// <param name="target">The target of the action (region / agent UUID, etc)</param>
|
||||||
|
/// <param name="methodCall">The method call where the problem occured</param>
|
||||||
|
/// <param name="arguments">The arguments passed to the method</param>
|
||||||
|
/// <param name="priority">How critical is this?</param>
|
||||||
|
/// <param name="logMessage">The message to log</param>
|
||||||
public void saveLog(string serverDaemon, string target, string methodCall, string arguments, int priority, string logMessage)
|
public void saveLog(string serverDaemon, string target, string methodCall, string arguments, int priority, string logMessage)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -33,16 +77,27 @@ namespace OpenGrid.Framework.Data.MySQL
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the name of this DB provider
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>A string containing the DB provider name</returns>
|
||||||
public string getName()
|
public string getName()
|
||||||
{
|
{
|
||||||
return "MySQL Logdata Interface";
|
return "MySQL Logdata Interface";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Closes the database provider
|
||||||
|
/// </summary>
|
||||||
public void Close()
|
public void Close()
|
||||||
{
|
{
|
||||||
// Do nothing.
|
// Do nothing.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the version of this DB provider
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>A string containing the provider version</returns>
|
||||||
public string getVersion()
|
public string getVersion()
|
||||||
{
|
{
|
||||||
return "0.1";
|
return "0.1";
|
||||||
|
|
|
@ -1,3 +1,29 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) OpenSim project, http://sim.opensecondlife.org/
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of the <organization> nor the
|
||||||
|
* names of its contributors may be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
|
||||||
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
*/
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
@ -13,9 +39,18 @@ using OpenGrid.Framework.Data;
|
||||||
|
|
||||||
namespace OpenGrid.Framework.Data.MySQL
|
namespace OpenGrid.Framework.Data.MySQL
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// A MySQL Database manager
|
||||||
|
/// </summary>
|
||||||
class MySQLManager
|
class MySQLManager
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The database connection object
|
||||||
|
/// </summary>
|
||||||
IDbConnection dbcon;
|
IDbConnection dbcon;
|
||||||
|
/// <summary>
|
||||||
|
/// Connection string for ADO.net
|
||||||
|
/// </summary>
|
||||||
string connectionString;
|
string connectionString;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -137,6 +172,11 @@ namespace OpenGrid.Framework.Data.MySQL
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Reads a region row from a database reader
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="reader">An active database reader</param>
|
||||||
|
/// <returns>A region profile</returns>
|
||||||
public SimProfileData readSimRow(IDataReader reader)
|
public SimProfileData readSimRow(IDataReader reader)
|
||||||
{
|
{
|
||||||
SimProfileData retval = new SimProfileData();
|
SimProfileData retval = new SimProfileData();
|
||||||
|
@ -199,6 +239,11 @@ namespace OpenGrid.Framework.Data.MySQL
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Reads an agent row from a database reader
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="reader">An active database reader</param>
|
||||||
|
/// <returns>A user session agent</returns>
|
||||||
public UserAgentData readAgentRow(IDataReader reader)
|
public UserAgentData readAgentRow(IDataReader reader)
|
||||||
{
|
{
|
||||||
UserAgentData retval = new UserAgentData();
|
UserAgentData retval = new UserAgentData();
|
||||||
|
@ -231,6 +276,11 @@ namespace OpenGrid.Framework.Data.MySQL
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Reads a user profile from an active data reader
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="reader">An active database reader</param>
|
||||||
|
/// <returns>A user profile</returns>
|
||||||
public UserProfileData readUserRow(IDataReader reader)
|
public UserProfileData readUserRow(IDataReader reader)
|
||||||
{
|
{
|
||||||
UserProfileData retval = new UserProfileData();
|
UserProfileData retval = new UserProfileData();
|
||||||
|
@ -344,6 +394,16 @@ namespace OpenGrid.Framework.Data.MySQL
|
||||||
return rows;
|
return rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Inserts a new row into the log database
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="serverDaemon">The daemon which triggered this event</param>
|
||||||
|
/// <param name="target">Who were we operating on when this occured (region UUID, user UUID, etc)</param>
|
||||||
|
/// <param name="methodCall">The method call where the problem occured</param>
|
||||||
|
/// <param name="arguments">The arguments passed to the method</param>
|
||||||
|
/// <param name="priority">How critical is this?</param>
|
||||||
|
/// <param name="logMessage">Extra message info</param>
|
||||||
|
/// <returns>Saved successfully?</returns>
|
||||||
public bool insertLogRow(string serverDaemon, string target, string methodCall, string arguments, int priority, string logMessage)
|
public bool insertLogRow(string serverDaemon, string target, string methodCall, string arguments, int priority, string logMessage)
|
||||||
{
|
{
|
||||||
string sql = "INSERT INTO logs (`target`, `server`, `method`, `arguments`, `priority`, `message`) VALUES ";
|
string sql = "INSERT INTO logs (`target`, `server`, `method`, `arguments`, `priority`, `message`) VALUES ";
|
||||||
|
@ -377,6 +437,11 @@ namespace OpenGrid.Framework.Data.MySQL
|
||||||
return returnval;
|
return returnval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Inserts a new item into the database
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="item">The item</param>
|
||||||
|
/// <returns>Success?</returns>
|
||||||
public bool insertItem(InventoryItemBase item)
|
public bool insertItem(InventoryItemBase item)
|
||||||
{
|
{
|
||||||
string sql = "REPLACE INTO inventoryitems (inventoryID, assetID, type, parentFolderID, avatarID, inventoryName, inventoryDescription, inventoryNextPermissions, inventoryCurrentPermissions) VALUES ";
|
string sql = "REPLACE INTO inventoryitems (inventoryID, assetID, type, parentFolderID, avatarID, inventoryName, inventoryDescription, inventoryNextPermissions, inventoryCurrentPermissions) VALUES ";
|
||||||
|
@ -413,6 +478,11 @@ namespace OpenGrid.Framework.Data.MySQL
|
||||||
return returnval;
|
return returnval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Inserts a new folder into the database
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="folder">The folder</param>
|
||||||
|
/// <returns>Success?</returns>
|
||||||
public bool insertFolder(InventoryFolderBase folder)
|
public bool insertFolder(InventoryFolderBase folder)
|
||||||
{
|
{
|
||||||
string sql = "REPLACE INTO inventoryfolders (folderID, agentID, parentFolderID, folderName) VALUES ";
|
string sql = "REPLACE INTO inventoryfolders (folderID, agentID, parentFolderID, folderName) VALUES ";
|
||||||
|
@ -442,7 +512,12 @@ namespace OpenGrid.Framework.Data.MySQL
|
||||||
return returnval;
|
return returnval;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool insertRow(SimProfileData profile)
|
/// <summary>
|
||||||
|
/// Inserts a new region into the database
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="profile">The region to insert</param>
|
||||||
|
/// <returns>Success?</returns>
|
||||||
|
public bool insertRegion(SimProfileData regiondata)
|
||||||
{
|
{
|
||||||
string sql = "REPLACE INTO regions (regionHandle, regionName, uuid, regionRecvKey, regionSecret, regionSendKey, regionDataURI, ";
|
string sql = "REPLACE INTO regions (regionHandle, regionName, uuid, regionRecvKey, regionSecret, regionSendKey, regionDataURI, ";
|
||||||
sql += "serverIP, serverPort, serverURI, locX, locY, locZ, eastOverrideHandle, westOverrideHandle, southOverrideHandle, northOverrideHandle, regionAssetURI, regionAssetRecvKey, ";
|
sql += "serverIP, serverPort, serverURI, locX, locY, locZ, eastOverrideHandle, westOverrideHandle, southOverrideHandle, northOverrideHandle, regionAssetURI, regionAssetRecvKey, ";
|
||||||
|
@ -454,30 +529,30 @@ namespace OpenGrid.Framework.Data.MySQL
|
||||||
|
|
||||||
Dictionary<string, string> parameters = new Dictionary<string, string>();
|
Dictionary<string, string> parameters = new Dictionary<string, string>();
|
||||||
|
|
||||||
parameters["?regionHandle"] = profile.regionHandle.ToString();
|
parameters["?regionHandle"] = regiondata.regionHandle.ToString();
|
||||||
parameters["?regionName"] = profile.regionName.ToString();
|
parameters["?regionName"] = regiondata.regionName.ToString();
|
||||||
parameters["?uuid"] = profile.UUID.ToStringHyphenated();
|
parameters["?uuid"] = regiondata.UUID.ToStringHyphenated();
|
||||||
parameters["?regionRecvKey"] = profile.regionRecvKey.ToString();
|
parameters["?regionRecvKey"] = regiondata.regionRecvKey.ToString();
|
||||||
parameters["?regionSecret"] = profile.regionSecret.ToString();
|
parameters["?regionSecret"] = regiondata.regionSecret.ToString();
|
||||||
parameters["?regionSendKey"] = profile.regionSendKey.ToString();
|
parameters["?regionSendKey"] = regiondata.regionSendKey.ToString();
|
||||||
parameters["?regionDataURI"] = profile.regionDataURI.ToString();
|
parameters["?regionDataURI"] = regiondata.regionDataURI.ToString();
|
||||||
parameters["?serverIP"] = profile.serverIP.ToString();
|
parameters["?serverIP"] = regiondata.serverIP.ToString();
|
||||||
parameters["?serverPort"] = profile.serverPort.ToString();
|
parameters["?serverPort"] = regiondata.serverPort.ToString();
|
||||||
parameters["?serverURI"] = profile.serverURI.ToString();
|
parameters["?serverURI"] = regiondata.serverURI.ToString();
|
||||||
parameters["?locX"] = profile.regionLocX.ToString();
|
parameters["?locX"] = regiondata.regionLocX.ToString();
|
||||||
parameters["?locY"] = profile.regionLocY.ToString();
|
parameters["?locY"] = regiondata.regionLocY.ToString();
|
||||||
parameters["?locZ"] = profile.regionLocZ.ToString();
|
parameters["?locZ"] = regiondata.regionLocZ.ToString();
|
||||||
parameters["?eastOverrideHandle"] = profile.regionEastOverrideHandle.ToString();
|
parameters["?eastOverrideHandle"] = regiondata.regionEastOverrideHandle.ToString();
|
||||||
parameters["?westOverrideHandle"] = profile.regionWestOverrideHandle.ToString();
|
parameters["?westOverrideHandle"] = regiondata.regionWestOverrideHandle.ToString();
|
||||||
parameters["?northOverrideHandle"] = profile.regionNorthOverrideHandle.ToString();
|
parameters["?northOverrideHandle"] = regiondata.regionNorthOverrideHandle.ToString();
|
||||||
parameters["?southOverrideHandle"] = profile.regionSouthOverrideHandle.ToString();
|
parameters["?southOverrideHandle"] = regiondata.regionSouthOverrideHandle.ToString();
|
||||||
parameters["?regionAssetURI"] = profile.regionAssetURI.ToString();
|
parameters["?regionAssetURI"] = regiondata.regionAssetURI.ToString();
|
||||||
parameters["?regionAssetRecvKey"] = profile.regionAssetRecvKey.ToString();
|
parameters["?regionAssetRecvKey"] = regiondata.regionAssetRecvKey.ToString();
|
||||||
parameters["?regionAssetSendKey"] = profile.regionAssetSendKey.ToString();
|
parameters["?regionAssetSendKey"] = regiondata.regionAssetSendKey.ToString();
|
||||||
parameters["?regionUserURI"] = profile.regionUserURI.ToString();
|
parameters["?regionUserURI"] = regiondata.regionUserURI.ToString();
|
||||||
parameters["?regionUserRecvKey"] = profile.regionUserRecvKey.ToString();
|
parameters["?regionUserRecvKey"] = regiondata.regionUserRecvKey.ToString();
|
||||||
parameters["?regionUserSendKey"] = profile.regionUserSendKey.ToString();
|
parameters["?regionUserSendKey"] = regiondata.regionUserSendKey.ToString();
|
||||||
parameters["?regionMapTexture"] = profile.regionMapTextureID.ToStringHyphenated();
|
parameters["?regionMapTexture"] = regiondata.regionMapTextureID.ToStringHyphenated();
|
||||||
|
|
||||||
bool returnval = false;
|
bool returnval = false;
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,29 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) OpenSim project, http://sim.opensecondlife.org/
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of the <organization> nor the
|
||||||
|
* names of its contributors may be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
|
||||||
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
*/
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
@ -6,12 +32,23 @@ using libsecondlife;
|
||||||
|
|
||||||
namespace OpenGrid.Framework.Data.MySQL
|
namespace OpenGrid.Framework.Data.MySQL
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// A database interface class to a user profile storage system
|
||||||
|
/// </summary>
|
||||||
class MySQLUserData : IUserData
|
class MySQLUserData : IUserData
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Database manager for MySQL
|
||||||
|
/// </summary>
|
||||||
public MySQLManager database;
|
public MySQLManager database;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Loads and initialises the MySQL storage plugin
|
||||||
|
/// </summary>
|
||||||
public void Initialise()
|
public void Initialise()
|
||||||
{
|
{
|
||||||
|
// Load from an INI file connection details
|
||||||
|
// TODO: move this to XML?
|
||||||
IniFile GridDataMySqlFile = new IniFile("mysql_connection.ini");
|
IniFile GridDataMySqlFile = new IniFile("mysql_connection.ini");
|
||||||
string settingHostname = GridDataMySqlFile.ParseFileReadValue("hostname");
|
string settingHostname = GridDataMySqlFile.ParseFileReadValue("hostname");
|
||||||
string settingDatabase = GridDataMySqlFile.ParseFileReadValue("database");
|
string settingDatabase = GridDataMySqlFile.ParseFileReadValue("database");
|
||||||
|
@ -23,11 +60,22 @@ namespace OpenGrid.Framework.Data.MySQL
|
||||||
database = new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling, settingPort);
|
database = new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling, settingPort);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Searches the database for a specified user profile
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name">The account name of the user</param>
|
||||||
|
/// <returns>A user profile</returns>
|
||||||
public UserProfileData getUserByName(string name)
|
public UserProfileData getUserByName(string name)
|
||||||
{
|
{
|
||||||
return getUserByName(name.Split(' ')[0], name.Split(' ')[1]);
|
return getUserByName(name.Split(' ')[0], name.Split(' ')[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Searches the database for a specified user profile by name components
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="user">The first part of the account name</param>
|
||||||
|
/// <param name="last">The second part of the account name</param>
|
||||||
|
/// <returns>A user profile</returns>
|
||||||
public UserProfileData getUserByName(string user, string last)
|
public UserProfileData getUserByName(string user, string last)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -57,6 +105,11 @@ namespace OpenGrid.Framework.Data.MySQL
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Searches the database for a specified user profile by UUID
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="uuid">The account ID</param>
|
||||||
|
/// <returns>The users profile</returns>
|
||||||
public UserProfileData getUserByUUID(LLUUID uuid)
|
public UserProfileData getUserByUUID(LLUUID uuid)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -85,17 +138,33 @@ namespace OpenGrid.Framework.Data.MySQL
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns a user session searching by name
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name">The account name</param>
|
||||||
|
/// <returns>The users session</returns>
|
||||||
public UserAgentData getAgentByName(string name)
|
public UserAgentData getAgentByName(string name)
|
||||||
{
|
{
|
||||||
return getAgentByName(name.Split(' ')[0], name.Split(' ')[1]);
|
return getAgentByName(name.Split(' ')[0], name.Split(' ')[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns a user session by account name
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="user">First part of the users account name</param>
|
||||||
|
/// <param name="last">Second part of the users account name</param>
|
||||||
|
/// <returns>The users session</returns>
|
||||||
public UserAgentData getAgentByName(string user, string last)
|
public UserAgentData getAgentByName(string user, string last)
|
||||||
{
|
{
|
||||||
UserProfileData profile = getUserByName(user, last);
|
UserProfileData profile = getUserByName(user, last);
|
||||||
return getAgentByUUID(profile.UUID);
|
return getAgentByUUID(profile.UUID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns an agent session by account UUID
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="uuid">The accounts UUID</param>
|
||||||
|
/// <returns>The users session</returns>
|
||||||
public UserAgentData getAgentByUUID(LLUUID uuid)
|
public UserAgentData getAgentByUUID(LLUUID uuid)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -124,30 +193,61 @@ namespace OpenGrid.Framework.Data.MySQL
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a new users profile
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="user">The user profile to create</param>
|
||||||
public void addNewUserProfile(UserProfileData user)
|
public void addNewUserProfile(UserProfileData user)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a new agent
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="agent">The agent to create</param>
|
||||||
public void addNewUserAgent(UserAgentData agent)
|
public void addNewUserAgent(UserAgentData agent)
|
||||||
{
|
{
|
||||||
// Do nothing.
|
// Do nothing.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Performs a money transfer request between two accounts
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="from">The senders account ID</param>
|
||||||
|
/// <param name="to">The recievers account ID</param>
|
||||||
|
/// <param name="amount">The amount to transfer</param>
|
||||||
|
/// <returns>Success?</returns>
|
||||||
public bool moneyTransferRequest(LLUUID from, LLUUID to, uint amount)
|
public bool moneyTransferRequest(LLUUID from, LLUUID to, uint amount)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Performs an inventory transfer request between two accounts
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>TODO: Move to inventory server</remarks>
|
||||||
|
/// <param name="from">The senders account ID</param>
|
||||||
|
/// <param name="to">The recievers account ID</param>
|
||||||
|
/// <param name="item">The item to transfer</param>
|
||||||
|
/// <returns>Success?</returns>
|
||||||
public bool inventoryTransferRequest(LLUUID from, LLUUID to, LLUUID item)
|
public bool inventoryTransferRequest(LLUUID from, LLUUID to, LLUUID item)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Database provider name
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>Provider name</returns>
|
||||||
public string getName()
|
public string getName()
|
||||||
{
|
{
|
||||||
return "MySQL Userdata Interface";
|
return "MySQL Userdata Interface";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Database provider version
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>provider version</returns>
|
||||||
public string getVersion()
|
public string getVersion()
|
||||||
{
|
{
|
||||||
return "0.1";
|
return "0.1";
|
||||||
|
|
Loading…
Reference in New Issue