From 8966ed9c82c8199bf0da61815d04d485d67aa34a Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Fri, 30 Apr 2010 21:37:31 +0100 Subject: [PATCH] fix an issue with user appearance where the new sqlite db adapter expects directly specification of byte[] type rather than base64 strings --- OpenSim/Data/SQLite/SQLiteUserData.cs | 37 +++++++++++++------ .../SQLiteLegacy/Resources/001_AuthStore.sql | 18 --------- .../SQLiteLegacy/Resources/001_Avatar.sql | 9 ----- .../Resources/001_FriendsStore.sql | 10 ----- .../Resources/001_UserAccount.sql | 17 --------- .../SQLiteLegacy/Resources/002_AuthStore.sql | 5 --- .../Resources/002_FriendsStore.sql | 5 --- .../Resources/002_UserAccount.sql | 5 --- 8 files changed, 25 insertions(+), 81 deletions(-) delete mode 100644 OpenSim/Data/SQLiteLegacy/Resources/001_AuthStore.sql delete mode 100644 OpenSim/Data/SQLiteLegacy/Resources/001_Avatar.sql delete mode 100644 OpenSim/Data/SQLiteLegacy/Resources/001_FriendsStore.sql delete mode 100644 OpenSim/Data/SQLiteLegacy/Resources/001_UserAccount.sql delete mode 100644 OpenSim/Data/SQLiteLegacy/Resources/002_AuthStore.sql delete mode 100644 OpenSim/Data/SQLiteLegacy/Resources/002_FriendsStore.sql delete mode 100644 OpenSim/Data/SQLiteLegacy/Resources/002_UserAccount.sql diff --git a/OpenSim/Data/SQLite/SQLiteUserData.cs b/OpenSim/Data/SQLite/SQLiteUserData.cs index 12db40322d..bffc0d0ab3 100644 --- a/OpenSim/Data/SQLite/SQLiteUserData.cs +++ b/OpenSim/Data/SQLite/SQLiteUserData.cs @@ -108,22 +108,32 @@ namespace OpenSim.Data.SQLite lock (ds) { + Console.WriteLine("Here1"); ds.Tables.Add(createUsersTable()); ds.Tables.Add(createUserAgentsTable()); ds.Tables.Add(createUserFriendsTable()); ds.Tables.Add(createAvatarAppearanceTable()); + Console.WriteLine("Here2"); setupUserCommands(da, conn); da.Fill(ds.Tables["users"]); + CreateDataSetMapping(da, "users"); + Console.WriteLine("Here3"); setupAgentCommands(dua, conn); dua.Fill(ds.Tables["useragents"]); + CreateDataSetMapping(dua, "useragents"); + Console.WriteLine("Here4"); setupUserFriendsCommands(daf, conn); daf.Fill(ds.Tables["userfriends"]); + CreateDataSetMapping(daf, "userfriends"); + Console.WriteLine("Here5"); setupAvatarAppearanceCommands(daa, conn); daa.Fill(ds.Tables["avatarappearance"]); + CreateDataSetMapping(daa, "avatarappearance"); + Console.WriteLine("Here6"); } return; @@ -706,15 +716,10 @@ namespace OpenSim.Data.SQLite aa.SkirtItem = new UUID((String)row["SkirtItem"]); aa.SkirtAsset = new UUID((String)row["SkirtAsset"]); - // Ewe Loon - // Used Base64String because for some reason it wont accept using Byte[] (which works in Region date) - - String str = (String)row["Texture"]; - byte[] texture = Convert.FromBase64String(str); + byte[] texture = (byte[])row["Texture"]; aa.Texture = new Primitive.TextureEntry(texture, 0, texture.Length); - str = (String)row["VisualParams"]; - byte[] VisualParams = Convert.FromBase64String(str); + byte[] VisualParams = (byte[])row["VisualParams"]; aa.VisualParams = VisualParams; aa.Serial = Convert.ToInt32(row["Serial"]); @@ -793,6 +798,15 @@ namespace OpenSim.Data.SQLite * **********************************************************************/ + protected void CreateDataSetMapping(IDataAdapter da, string tableName) + { + ITableMapping dbMapping = da.TableMappings.Add(tableName, tableName); + foreach (DataColumn col in ds.Tables[tableName].Columns) + { + dbMapping.ColumnMappings.Add(col.ColumnName, col.ColumnName); + } + } + /// /// Create the "users" table /// @@ -924,9 +938,8 @@ namespace OpenSim.Data.SQLite SQLiteUtil.createCol(aa, "SkirtItem", typeof(String)); SQLiteUtil.createCol(aa, "SkirtAsset", typeof(String)); - // Used Base64String because for some reason it wont accept using Byte[] (which works in Region date) - SQLiteUtil.createCol(aa, "Texture", typeof (String)); - SQLiteUtil.createCol(aa, "VisualParams", typeof (String)); + SQLiteUtil.createCol(aa, "Texture", typeof (Byte[])); + SQLiteUtil.createCol(aa, "VisualParams", typeof (Byte[])); SQLiteUtil.createCol(aa, "Serial", typeof(Int32)); SQLiteUtil.createCol(aa, "AvatarHeight", typeof(Double)); @@ -1090,8 +1103,8 @@ namespace OpenSim.Data.SQLite row["SkirtAsset"] = appearance.SkirtAsset.ToString(); // Used Base64String because for some reason it wont accept using Byte[] (which works in Region date) - row["Texture"] = Convert.ToBase64String(appearance.Texture.GetBytes()); - row["VisualParams"] = Convert.ToBase64String(appearance.VisualParams); + row["Texture"] = appearance.Texture.GetBytes(); + row["VisualParams"] = appearance.VisualParams; row["Serial"] = appearance.Serial; row["AvatarHeight"] = appearance.AvatarHeight; diff --git a/OpenSim/Data/SQLiteLegacy/Resources/001_AuthStore.sql b/OpenSim/Data/SQLiteLegacy/Resources/001_AuthStore.sql deleted file mode 100644 index 468567dcc2..0000000000 --- a/OpenSim/Data/SQLiteLegacy/Resources/001_AuthStore.sql +++ /dev/null @@ -1,18 +0,0 @@ -BEGIN TRANSACTION; - -CREATE TABLE auth ( - UUID char(36) NOT NULL, - passwordHash char(32) NOT NULL default '', - passwordSalt char(32) NOT NULL default '', - webLoginKey varchar(255) NOT NULL default '', - accountType VARCHAR(32) NOT NULL DEFAULT 'UserAccount', - PRIMARY KEY (`UUID`) -); - -CREATE TABLE tokens ( - UUID char(36) NOT NULL, - token varchar(255) NOT NULL, - validity datetime NOT NULL -); - -COMMIT; diff --git a/OpenSim/Data/SQLiteLegacy/Resources/001_Avatar.sql b/OpenSim/Data/SQLiteLegacy/Resources/001_Avatar.sql deleted file mode 100644 index 7ec906b48a..0000000000 --- a/OpenSim/Data/SQLiteLegacy/Resources/001_Avatar.sql +++ /dev/null @@ -1,9 +0,0 @@ -BEGIN TRANSACTION; - -CREATE TABLE Avatars ( - PrincipalID CHAR(36) NOT NULL, - Name VARCHAR(32) NOT NULL, - Value VARCHAR(255) NOT NULL DEFAULT '', - PRIMARY KEY(PrincipalID, Name)); - -COMMIT; diff --git a/OpenSim/Data/SQLiteLegacy/Resources/001_FriendsStore.sql b/OpenSim/Data/SQLiteLegacy/Resources/001_FriendsStore.sql deleted file mode 100644 index f1b9ab9902..0000000000 --- a/OpenSim/Data/SQLiteLegacy/Resources/001_FriendsStore.sql +++ /dev/null @@ -1,10 +0,0 @@ -BEGIN TRANSACTION; - -CREATE TABLE `Friends` ( - `PrincipalID` CHAR(36) NOT NULL, - `Friend` VARCHAR(255) NOT NULL, - `Flags` VARCHAR(16) NOT NULL DEFAULT 0, - `Offered` VARCHAR(32) NOT NULL DEFAULT 0, - PRIMARY KEY(`PrincipalID`, `Friend`)); - -COMMIT; diff --git a/OpenSim/Data/SQLiteLegacy/Resources/001_UserAccount.sql b/OpenSim/Data/SQLiteLegacy/Resources/001_UserAccount.sql deleted file mode 100644 index c38d9a762f..0000000000 --- a/OpenSim/Data/SQLiteLegacy/Resources/001_UserAccount.sql +++ /dev/null @@ -1,17 +0,0 @@ -BEGIN TRANSACTION; - --- useraccounts table -CREATE TABLE UserAccounts ( - PrincipalID CHAR(36) primary key, - ScopeID CHAR(36) NOT NULL, - FirstName VARCHAR(64) NOT NULL, - LastName VARCHAR(64) NOT NULL, - Email VARCHAR(64), - ServiceURLs TEXT, - Created INT(11), - UserLevel integer NOT NULL DEFAULT 0, - UserFlags integer NOT NULL DEFAULT 0, - UserTitle varchar(64) NOT NULL DEFAULT '' -); - -COMMIT; \ No newline at end of file diff --git a/OpenSim/Data/SQLiteLegacy/Resources/002_AuthStore.sql b/OpenSim/Data/SQLiteLegacy/Resources/002_AuthStore.sql deleted file mode 100644 index 3237b68fd6..0000000000 --- a/OpenSim/Data/SQLiteLegacy/Resources/002_AuthStore.sql +++ /dev/null @@ -1,5 +0,0 @@ -BEGIN TRANSACTION; - -INSERT INTO auth (UUID, passwordHash, passwordSalt, webLoginKey) SELECT `UUID` AS UUID, `passwordHash` AS passwordHash, `passwordSalt` AS passwordSalt, `webLoginKey` AS webLoginKey FROM users; - -COMMIT; diff --git a/OpenSim/Data/SQLiteLegacy/Resources/002_FriendsStore.sql b/OpenSim/Data/SQLiteLegacy/Resources/002_FriendsStore.sql deleted file mode 100644 index 6733502224..0000000000 --- a/OpenSim/Data/SQLiteLegacy/Resources/002_FriendsStore.sql +++ /dev/null @@ -1,5 +0,0 @@ -BEGIN TRANSACTION; - -INSERT INTO `Friends` SELECT `ownerID`, `friendID`, `friendPerms`, 0 FROM `userfriends`; - -COMMIT; diff --git a/OpenSim/Data/SQLiteLegacy/Resources/002_UserAccount.sql b/OpenSim/Data/SQLiteLegacy/Resources/002_UserAccount.sql deleted file mode 100644 index c7a62932ac..0000000000 --- a/OpenSim/Data/SQLiteLegacy/Resources/002_UserAccount.sql +++ /dev/null @@ -1,5 +0,0 @@ -BEGIN TRANSACTION; - -INSERT INTO UserAccounts (PrincipalID, ScopeID, FirstName, LastName, Email, ServiceURLs, Created) SELECT `UUID` AS PrincipalID, '00000000-0000-0000-0000-000000000000' AS ScopeID, username AS FirstName, surname AS LastName, '' as Email, '' AS ServiceURLs, created as Created FROM users; - -COMMIT;