From 04488d9d3819fd16502a095771d1513af02b7a93 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Fri, 15 Aug 2008 22:49:26 +0000 Subject: Plumb in the partner and the account title fields for profile info. --- OpenSim/Data/MySQL/MySQLManager.cs | 27 +++++++++++++++++--- OpenSim/Data/MySQL/MySQLUserData.cs | 2 +- OpenSim/Data/MySQL/Resources/004_UserStore.sql | 6 +++++ OpenSim/Data/SQLite/Resources/004_UserStore.sql | 6 +++++ OpenSim/Data/SQLite/SQLiteUserData.cs | 6 +++++ OpenSim/Framework/UserProfileData.cs | 14 +++++++++++ OpenSim/Grid/UserServer/UserManager.cs | 29 ++++++++++++++++++++++ .../Region/Communications/OGS1/OGS1UserServices.cs | 14 +++++++++++ .../Avatar/Profiles/AvatarProfilesModule.cs | 15 ++++++++--- 9 files changed, 110 insertions(+), 9 deletions(-) create mode 100644 OpenSim/Data/MySQL/Resources/004_UserStore.sql create mode 100644 OpenSim/Data/SQLite/Resources/004_UserStore.sql (limited to 'OpenSim') diff --git a/OpenSim/Data/MySQL/MySQLManager.cs b/OpenSim/Data/MySQL/MySQLManager.cs index d2b436c..58599a8 100644 --- a/OpenSim/Data/MySQL/MySQLManager.cs +++ b/OpenSim/Data/MySQL/MySQLManager.cs @@ -590,7 +590,21 @@ namespace OpenSim.Data.MySQL retval.UserFlags = Convert.ToInt32(reader["userFlags"].ToString()); retval.GodLevel = Convert.ToInt32(reader["godLevel"].ToString()); - + if (reader.IsDBNull(reader.GetOrdinal("customType"))) + retval.CustomType = ""; + else + retval.CustomType = reader["customType"].ToString(); + + if (reader.IsDBNull(reader.GetOrdinal("partner"))) + { + retval.Partner = LLUUID.Zero; + } + else + { + LLUUID tmp; + LLUUID.TryParse((string)reader["partner"], out tmp); + retval.Partner = tmp; + } } else { @@ -731,14 +745,14 @@ namespace OpenSim.Data.MySQL "`homeLocationX`, `homeLocationY`, `homeLocationZ`, `homeLookAtX`, `homeLookAtY`, `homeLookAtZ`, `created`, "; sql += "`lastLogin`, `userInventoryURI`, `userAssetURI`, `profileCanDoMask`, `profileWantDoMask`, `profileAboutText`, "; - sql += "`profileFirstText`, `profileImage`, `profileFirstImage`, `webLoginKey`, `userFlags`, `godLevel`) VALUES "; + sql += "`profileFirstText`, `profileImage`, `profileFirstImage`, `webLoginKey`, `userFlags`, `godLevel`, `customType`, `partner`) VALUES "; sql += "(?UUID, ?username, ?lastname, ?passwordHash, ?passwordSalt, ?homeRegion, "; sql += "?homeLocationX, ?homeLocationY, ?homeLocationZ, ?homeLookAtX, ?homeLookAtY, ?homeLookAtZ, ?created, "; sql += "?lastLogin, ?userInventoryURI, ?userAssetURI, ?profileCanDoMask, ?profileWantDoMask, ?profileAboutText, "; - sql += "?profileFirstText, ?profileImage, ?profileFirstImage, ?webLoginKey, ?userFlags, ?godLevel)"; + sql += "?profileFirstText, ?profileImage, ?profileFirstImage, ?webLoginKey, ?userFlags, ?godLevel, ?customType, ?partner)"; Dictionary parameters = new Dictionary(); parameters["?UUID"] = uuid.ToString(); @@ -766,6 +780,8 @@ namespace OpenSim.Data.MySQL parameters["?webLoginKey"] = string.Empty; parameters["?userFlags"] = "0"; parameters["?godLevel"] = "0"; + parameters["?customType"] = ""; + parameters["?partner"] = ""; bool returnval = false; @@ -821,7 +837,7 @@ namespace OpenSim.Data.MySQL float homeLookAtX, float homeLookAtY, float homeLookAtZ, int created, int lastlogin, string inventoryURI, string assetURI, uint canDoMask, uint wantDoMask, string aboutText, string firstText, - LLUUID profileImage, LLUUID firstImage, LLUUID webLoginKey, int userFlags, int godLevel) + LLUUID profileImage, LLUUID firstImage, LLUUID webLoginKey, int userFlags, int godLevel, string customType, LLUUID partner) { string sql = "UPDATE users SET `username` = ?username , `lastname` = ?lastname "; sql += ", `passwordHash` = ?passwordHash , `passwordSalt` = ?passwordSalt , "; @@ -834,6 +850,7 @@ namespace OpenSim.Data.MySQL sql += "`profileAboutText` = ?profileAboutText , `profileFirstText` = ?profileFirstText, "; sql += "`profileImage` = ?profileImage , `profileFirstImage` = ?profileFirstImage , "; sql += "`userFlags` = ?userFlags , `godLevel` = ?godLevel , "; + sql += "`customType` = ?customType , `partner` = ?partner , "; sql += "`webLoginKey` = ?webLoginKey WHERE UUID = ?UUID"; Dictionary parameters = new Dictionary(); @@ -863,6 +880,8 @@ namespace OpenSim.Data.MySQL parameters["?webLoginKey"] = webLoginKey.ToString(); parameters["?userFlags"] = userFlags.ToString(); parameters["?godLevel"] = godLevel.ToString(); + parameters["?customType"] = customType.ToString(); + parameters["?partner"] = partner.ToString(); bool returnval = false; try diff --git a/OpenSim/Data/MySQL/MySQLUserData.cs b/OpenSim/Data/MySQL/MySQLUserData.cs index b7f4cbd..f77d947 100644 --- a/OpenSim/Data/MySQL/MySQLUserData.cs +++ b/OpenSim/Data/MySQL/MySQLUserData.cs @@ -685,7 +685,7 @@ namespace OpenSim.Data.MySQL user.HomeRegion, user.HomeRegionID, user.HomeLocation.X, user.HomeLocation.Y, user.HomeLocation.Z, user.HomeLookAt.X, user.HomeLookAt.Y, user.HomeLookAt.Z, user.Created, user.LastLogin, user.UserInventoryURI, user.UserAssetURI, user.CanDoMask, user.WantDoMask, user.AboutText, - user.FirstLifeAboutText, user.Image, user.FirstLifeImage, user.WebLoginKey, user.UserFlags, user.GodLevel); + user.FirstLifeAboutText, user.Image, user.FirstLifeImage, user.WebLoginKey, user.UserFlags, user.GodLevel, user.CustomType, user.Partner); } return true; diff --git a/OpenSim/Data/MySQL/Resources/004_UserStore.sql b/OpenSim/Data/MySQL/Resources/004_UserStore.sql new file mode 100644 index 0000000..03142af --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/004_UserStore.sql @@ -0,0 +1,6 @@ +BEGIN; + +ALTER TABLE users add customType varchar(32) not null default ''; +ALTER TABLE users add partner char(36) not null default '00000000-0000-0000-0000-000000000000'; + +COMMIT; diff --git a/OpenSim/Data/SQLite/Resources/004_UserStore.sql b/OpenSim/Data/SQLite/Resources/004_UserStore.sql new file mode 100644 index 0000000..03142af --- /dev/null +++ b/OpenSim/Data/SQLite/Resources/004_UserStore.sql @@ -0,0 +1,6 @@ +BEGIN; + +ALTER TABLE users add customType varchar(32) not null default ''; +ALTER TABLE users add partner char(36) not null default '00000000-0000-0000-0000-000000000000'; + +COMMIT; diff --git a/OpenSim/Data/SQLite/SQLiteUserData.cs b/OpenSim/Data/SQLite/SQLiteUserData.cs index c55eee8..910d313 100644 --- a/OpenSim/Data/SQLite/SQLiteUserData.cs +++ b/OpenSim/Data/SQLite/SQLiteUserData.cs @@ -683,6 +683,8 @@ namespace OpenSim.Data.SQLite SQLiteUtil.createCol(users, "webLoginKey", typeof(String)); SQLiteUtil.createCol(users, "userFlags", typeof (Int32)); SQLiteUtil.createCol(users, "godLevel", typeof (Int32)); + SQLiteUtil.createCol(users, "customType", typeof (String)); + SQLiteUtil.createCol(users, "partner", typeof (String)); // Add in contraints users.PrimaryKey = new DataColumn[] {users.Columns["UUID"]}; return users; @@ -793,6 +795,8 @@ namespace OpenSim.Data.SQLite user.WebLoginKey = new LLUUID((String) row["webLoginKey"]); user.UserFlags = Convert.ToInt32(row["userFlags"]); user.GodLevel = Convert.ToInt32(row["godLevel"]); + user.CustomType = row["customType"].ToString(); + user.Partner = new LLUUID((String) row["partner"]); return user; } @@ -835,6 +839,8 @@ namespace OpenSim.Data.SQLite row["webLoginKey"] = user.WebLoginKey; row["userFlags"] = user.UserFlags; row["godLevel"] = user.GodLevel; + row["customType"] = user.CustomType; + row["partner"] = user.Partner.ToString(); // ADO.NET doesn't handle NULL very well foreach (DataColumn col in ds.Tables["users"].Columns) diff --git a/OpenSim/Framework/UserProfileData.cs b/OpenSim/Framework/UserProfileData.cs index ec9c473..d0b4c25 100644 --- a/OpenSim/Framework/UserProfileData.cs +++ b/OpenSim/Framework/UserProfileData.cs @@ -141,6 +141,8 @@ namespace OpenSim.Framework // private int _userFlags; private int _godLevel; + private string _customType; + private LLUUID _partner; /// /// The regionhandle of the users preffered home region. If multiple sims occupy the same spot, the grid may decide which region the user logs into @@ -348,5 +350,17 @@ namespace OpenSim.Framework get { return _godLevel; } set { _godLevel = value; } } + + public virtual string CustomType + { + get { return _customType; } + set { _customType = value; } + } + + public virtual LLUUID Partner + { + get { return _partner; } + set { _partner = value; } + } } } diff --git a/OpenSim/Grid/UserServer/UserManager.cs b/OpenSim/Grid/UserServer/UserManager.cs index 5506631..b1d95da 100644 --- a/OpenSim/Grid/UserServer/UserManager.cs +++ b/OpenSim/Grid/UserServer/UserManager.cs @@ -159,6 +159,8 @@ namespace OpenSim.Grid.UserServer responseData["user_flags"] = profile.UserFlags.ToString(); responseData["god_level"] = profile.GodLevel.ToString(); + responseData["custom_type"] = profile.CustomType.ToString(); + responseData["partner"] = profile.Partner.ToString(); response.Value = responseData; return response; @@ -663,6 +665,33 @@ namespace OpenSim.Grid.UserServer m_log.Error("[PROFILE]:Failed to set god level"); } } + if (requestData.Contains("custom_type")) + { + try + { + userProfile.CustomType = (string)requestData["custom_type"]; + } + catch (InvalidCastException) + { + m_log.Error("[PROFILE]:Failed to set custom type"); + } + } + if (requestData.Contains("partner")) + { + try + { + userProfile.Partner = new LLUUID((string)requestData["partner"]); + } + catch (InvalidCastException) + { + m_log.Error("[PROFILE]:Failed to set partner"); + } + } + else + { + userProfile.Partner = LLUUID.Zero; + } + // call plugin! bool ret = UpdateUserProfileProperties(userProfile); responseData["returnString"] = ret.ToString(); diff --git a/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs b/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs index 01b1933..3d42dfd 100644 --- a/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs +++ b/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs @@ -92,6 +92,18 @@ namespace OpenSim.Region.Communications.OGS1 if (data.Contains("god_level")) userData.GodLevel = Convert.ToInt32((string) data["god_level"]); + if (data.Contains("custom_type")) + userData.CustomType = (string) data["custom_type"]; + else + userData.CustomType = ""; + if(userData.CustomType == null) + userData.CustomType = ""; + + if (data.Contains("partner")) + userData.Partner = new LLUUID((string) data["partner"]); + else + userData.Partner = LLUUID.Zero; + return userData; } @@ -471,6 +483,8 @@ namespace OpenSim.Region.Communications.OGS1 param["home_look_z"] = UserProfile.HomeLookAtZ.ToString(); param["user_flags"] = UserProfile.UserFlags.ToString(); param["god_level"] = UserProfile.GodLevel.ToString(); + param["custom_type"] = UserProfile.CustomType.ToString(); + param["partner"] = UserProfile.Partner.ToString(); IList parameters = new ArrayList(); parameters.Add(param); diff --git a/OpenSim/Region/Environment/Modules/Avatar/Profiles/AvatarProfilesModule.cs b/OpenSim/Region/Environment/Modules/Avatar/Profiles/AvatarProfilesModule.cs index 881889f..1d1d503 100644 --- a/OpenSim/Region/Environment/Modules/Avatar/Profiles/AvatarProfilesModule.cs +++ b/OpenSim/Region/Environment/Modules/Avatar/Profiles/AvatarProfilesModule.cs @@ -93,17 +93,24 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Profiles public void RequestAvatarProperty(IClientAPI remoteClient, LLUUID avatarID) { // FIXME: finish adding fields such as url, masking, etc. - LLUUID partner = new LLUUID("11111111-1111-0000-0000-000100bba000"); UserProfileData profile = m_scene.CommsManager.UserService.GetUserProfile(avatarID); if (null != profile) { - Byte[] charterMember = new Byte[1]; - charterMember[0] = (Byte)((profile.UserFlags & 0xf00) >> 8); + Byte[] charterMember; + if(profile.CustomType == "") + { + charterMember = new Byte[1]; + charterMember[0] = (Byte)((profile.UserFlags & 0xf00) >> 8); + } + else + { + charterMember = Helpers.StringToField(profile.CustomType); + } remoteClient.SendAvatarProperties(profile.ID, profile.AboutText, Util.ToDateTime(profile.Created).ToString(), charterMember, profile.FirstLifeAboutText, (uint)(profile.UserFlags & 0xff), - profile.FirstLifeImage, profile.Image, String.Empty, partner); + profile.FirstLifeImage, profile.Image, String.Empty, profile.Partner); } else { -- cgit v1.1