in theory, this moves the appearance mapper to live

under the MySQLUserData.  There is a lot of in theory here
so testing would be appreciated.
0.6.0-stable
Sean Dague 2008-05-16 14:30:25 +00:00
parent e6d4c8f0c9
commit 0076ed40ff
2 changed files with 71 additions and 35 deletions

View File

@ -33,6 +33,9 @@ using System.Text.RegularExpressions;
using libsecondlife;
using log4net;
using OpenSim.Framework;
using OpenSim.Data.Base;
using OpenSim.Data.MapperFactory;
using OpenSim.Data.MySQLMapper;
namespace OpenSim.Data.MySQL
{
@ -51,15 +54,20 @@ namespace OpenSim.Data.MySQL
private string m_agentsTableName;
private string m_usersTableName;
private string m_userFriendsTableName;
private string m_connectString;
private BaseDatabaseConnector m_databaseMapper;
private AppearanceTableMapper m_appearanceMapper;
/// <summary>
/// Loads and initialises the MySQL storage plugin
/// </summary>
override public void Initialise(string connect)
{
if (connect == String.Empty) {
// TODO: actually do something with our connect string
// instead of loading the second config
m_log.Warn("Using obsoletely mysql_connection.ini, try using user_source connect string instead");
IniFile iniFile = new IniFile("mysql_connection.ini");
string settingHostname = iniFile.ParseFileReadValue("hostname");
string settingDatabase = iniFile.ParseFileReadValue("database");
@ -86,9 +94,25 @@ namespace OpenSim.Data.MySQL
m_agentsTableName = "agents";
}
database =
new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling,
settingPort);
m_connectString = "Server=" + settingHostname + ";Port=" + settingPort + ";Database=" + settingDatabase + ";User ID=" +
settingUsername + ";Password=" + settingPassword + ";Pooling=" + settingPooling + ";";
database = new MySQLManager(m_connectString);
} else {
m_connectString = connect;
m_agentsTableName = "agents";
m_usersTableName = "users";
m_userFriendsTableName = "userfriends";
}
string mapperTypeStr = "MySQL";
DataMapperFactory.MAPPER_TYPE mapperType =
(DataMapperFactory.MAPPER_TYPE)
Enum.Parse(typeof (DataMapperFactory.MAPPER_TYPE), mapperTypeStr);
m_databaseMapper = DataMapperFactory.GetDataBaseMapper(mapperType, m_connectString);
m_appearanceMapper = new AppearanceTableMapper(m_databaseMapper, "AvatarAppearance");
TestTables();
}
@ -630,15 +654,24 @@ namespace OpenSim.Data.MySQL
/// Appearance
/// TODO: stubs for now to get us to a compiling state gently
// override public AvatarAppearance GetUserAppearance(LLUUID user)
// {
// return new AvatarAppearance();
// }
// override
public AvatarAppearance GetUserAppearance(LLUUID user)
{
AvatarAppearance appearance = null;
if (!m_appearanceMapper.TryGetValue(user.UUID, out appearance))
{
appearance = new AvatarAppearance();
appearance.Owner = user;
UpdateUserAppearance(user, appearance);
}
return appearance;
}
// override public void UpdateUserAppearance(LLUUID user, AvatarAppearance appearance)
// {
// return;
// }
// override
public void UpdateUserAppearance(LLUUID user, AvatarAppearance appearance)
{
m_appearanceMapper.Update(user.UUID, appearance);
}
override public void AddAttachment(LLUUID user, LLUUID item)
{

View File

@ -1272,6 +1272,9 @@
<Reference name="System.Data"/>
<Reference name="OpenSim.Framework"/>
<Reference name="OpenSim.Data"/>
<Reference name="OpenSim.Data.MapperFactory"/>
<Reference name="OpenSim.Data.Base"/>
<Reference name="OpenSim.Data.MySQLMapper"/>
<Reference name="libsecondlife.dll"/>
<Reference name="MySql.Data.dll"/>
<Reference name="OpenSim.Framework.Console"/>