diff options
author | Sean Dague | 2008-05-16 14:30:25 +0000 |
---|---|---|
committer | Sean Dague | 2008-05-16 14:30:25 +0000 |
commit | 0076ed40ffd971f361244ffc894f0c78b2ae6d79 (patch) | |
tree | 9a898801b0c109f72157f4e770d0f02eae9e5343 /OpenSim/Data | |
parent | move AppearanceTableMapper to OpenSim.Data.Base. The mapper (diff) | |
download | opensim-SC-0076ed40ffd971f361244ffc894f0c78b2ae6d79.zip opensim-SC-0076ed40ffd971f361244ffc894f0c78b2ae6d79.tar.gz opensim-SC-0076ed40ffd971f361244ffc894f0c78b2ae6d79.tar.bz2 opensim-SC-0076ed40ffd971f361244ffc894f0c78b2ae6d79.tar.xz |
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.
Diffstat (limited to 'OpenSim/Data')
-rw-r--r-- | OpenSim/Data/MySQL/MySQLUserData.cs | 107 |
1 files changed, 70 insertions, 37 deletions
diff --git a/OpenSim/Data/MySQL/MySQLUserData.cs b/OpenSim/Data/MySQL/MySQLUserData.cs index 0acf47b..cab1608 100644 --- a/OpenSim/Data/MySQL/MySQLUserData.cs +++ b/OpenSim/Data/MySQL/MySQLUserData.cs | |||
@@ -33,6 +33,9 @@ using System.Text.RegularExpressions; | |||
33 | using libsecondlife; | 33 | using libsecondlife; |
34 | using log4net; | 34 | using log4net; |
35 | using OpenSim.Framework; | 35 | using OpenSim.Framework; |
36 | using OpenSim.Data.Base; | ||
37 | using OpenSim.Data.MapperFactory; | ||
38 | using OpenSim.Data.MySQLMapper; | ||
36 | 39 | ||
37 | namespace OpenSim.Data.MySQL | 40 | namespace OpenSim.Data.MySQL |
38 | { | 41 | { |
@@ -51,44 +54,65 @@ namespace OpenSim.Data.MySQL | |||
51 | private string m_agentsTableName; | 54 | private string m_agentsTableName; |
52 | private string m_usersTableName; | 55 | private string m_usersTableName; |
53 | private string m_userFriendsTableName; | 56 | private string m_userFriendsTableName; |
57 | private string m_connectString; | ||
58 | private BaseDatabaseConnector m_databaseMapper; | ||
59 | private AppearanceTableMapper m_appearanceMapper; | ||
54 | 60 | ||
55 | /// <summary> | 61 | /// <summary> |
56 | /// Loads and initialises the MySQL storage plugin | 62 | /// Loads and initialises the MySQL storage plugin |
57 | /// </summary> | 63 | /// </summary> |
58 | override public void Initialise(string connect) | 64 | override public void Initialise(string connect) |
59 | { | 65 | { |
60 | // TODO: actually do something with our connect string | 66 | if (connect == String.Empty) { |
61 | // instead of loading the second config | 67 | // TODO: actually do something with our connect string |
62 | 68 | // instead of loading the second config | |
63 | IniFile iniFile = new IniFile("mysql_connection.ini"); | 69 | |
64 | string settingHostname = iniFile.ParseFileReadValue("hostname"); | 70 | m_log.Warn("Using obsoletely mysql_connection.ini, try using user_source connect string instead"); |
65 | string settingDatabase = iniFile.ParseFileReadValue("database"); | 71 | IniFile iniFile = new IniFile("mysql_connection.ini"); |
66 | string settingUsername = iniFile.ParseFileReadValue("username"); | 72 | string settingHostname = iniFile.ParseFileReadValue("hostname"); |
67 | string settingPassword = iniFile.ParseFileReadValue("password"); | 73 | string settingDatabase = iniFile.ParseFileReadValue("database"); |
68 | string settingPooling = iniFile.ParseFileReadValue("pooling"); | 74 | string settingUsername = iniFile.ParseFileReadValue("username"); |
69 | string settingPort = iniFile.ParseFileReadValue("port"); | 75 | string settingPassword = iniFile.ParseFileReadValue("password"); |
70 | 76 | string settingPooling = iniFile.ParseFileReadValue("pooling"); | |
71 | m_usersTableName = iniFile.ParseFileReadValue("userstablename"); | 77 | string settingPort = iniFile.ParseFileReadValue("port"); |
72 | if (m_usersTableName == null) | 78 | |
73 | { | 79 | m_usersTableName = iniFile.ParseFileReadValue("userstablename"); |
74 | m_usersTableName = "users"; | 80 | if (m_usersTableName == null) |
75 | } | 81 | { |
82 | m_usersTableName = "users"; | ||
83 | } | ||
76 | 84 | ||
77 | m_userFriendsTableName = iniFile.ParseFileReadValue("userfriendstablename"); | 85 | m_userFriendsTableName = iniFile.ParseFileReadValue("userfriendstablename"); |
78 | if (m_userFriendsTableName == null) | 86 | if (m_userFriendsTableName == null) |
79 | { | 87 | { |
80 | m_userFriendsTableName = "userfriends"; | 88 | m_userFriendsTableName = "userfriends"; |
81 | } | 89 | } |
90 | |||
91 | m_agentsTableName = iniFile.ParseFileReadValue("agentstablename"); | ||
92 | if (m_agentsTableName == null) | ||
93 | { | ||
94 | m_agentsTableName = "agents"; | ||
95 | } | ||
82 | 96 | ||
83 | m_agentsTableName = iniFile.ParseFileReadValue("agentstablename"); | 97 | m_connectString = "Server=" + settingHostname + ";Port=" + settingPort + ";Database=" + settingDatabase + ";User ID=" + |
84 | if (m_agentsTableName == null) | 98 | settingUsername + ";Password=" + settingPassword + ";Pooling=" + settingPooling + ";"; |
85 | { | 99 | |
100 | database = new MySQLManager(m_connectString); | ||
101 | } else { | ||
102 | m_connectString = connect; | ||
86 | m_agentsTableName = "agents"; | 103 | m_agentsTableName = "agents"; |
104 | m_usersTableName = "users"; | ||
105 | m_userFriendsTableName = "userfriends"; | ||
87 | } | 106 | } |
88 | 107 | ||
89 | database = | 108 | string mapperTypeStr = "MySQL"; |
90 | new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling, | 109 | DataMapperFactory.MAPPER_TYPE mapperType = |
91 | settingPort); | 110 | (DataMapperFactory.MAPPER_TYPE) |
111 | Enum.Parse(typeof (DataMapperFactory.MAPPER_TYPE), mapperTypeStr); | ||
112 | |||
113 | m_databaseMapper = DataMapperFactory.GetDataBaseMapper(mapperType, m_connectString); | ||
114 | |||
115 | m_appearanceMapper = new AppearanceTableMapper(m_databaseMapper, "AvatarAppearance"); | ||
92 | 116 | ||
93 | TestTables(); | 117 | TestTables(); |
94 | } | 118 | } |
@@ -630,15 +654,24 @@ namespace OpenSim.Data.MySQL | |||
630 | 654 | ||
631 | /// Appearance | 655 | /// Appearance |
632 | /// TODO: stubs for now to get us to a compiling state gently | 656 | /// TODO: stubs for now to get us to a compiling state gently |
633 | // override public AvatarAppearance GetUserAppearance(LLUUID user) | 657 | // override |
634 | // { | 658 | public AvatarAppearance GetUserAppearance(LLUUID user) |
635 | // return new AvatarAppearance(); | 659 | { |
636 | // } | 660 | AvatarAppearance appearance = null; |
637 | 661 | if (!m_appearanceMapper.TryGetValue(user.UUID, out appearance)) | |
638 | // override public void UpdateUserAppearance(LLUUID user, AvatarAppearance appearance) | 662 | { |
639 | // { | 663 | appearance = new AvatarAppearance(); |
640 | // return; | 664 | appearance.Owner = user; |
641 | // } | 665 | UpdateUserAppearance(user, appearance); |
666 | } | ||
667 | return appearance; | ||
668 | } | ||
669 | |||
670 | // override | ||
671 | public void UpdateUserAppearance(LLUUID user, AvatarAppearance appearance) | ||
672 | { | ||
673 | m_appearanceMapper.Update(user.UUID, appearance); | ||
674 | } | ||
642 | 675 | ||
643 | override public void AddAttachment(LLUUID user, LLUUID item) | 676 | override public void AddAttachment(LLUUID user, LLUUID item) |
644 | { | 677 | { |