From 40eb8bc8b6abdd11530856d64384d4b1be9d5e4c Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Mon, 7 May 2007 04:26:22 +0000 Subject: [PATCH] * DB4o usermanager replacement coded for read-only attributes. * IUserData interface needs expansion to cover all user/user-server related interactions. --- OpenGrid.Framework.Data.DB4o/DB4oManager.cs | 4 +-- OpenGrid.Framework.Data.DB4o/DB4oUserData.cs | 35 ++++++++++++++++---- OpenGrid.Framework.Data/UserProfileData.cs | 33 +++++++++--------- 3 files changed, 48 insertions(+), 24 deletions(-) diff --git a/OpenGrid.Framework.Data.DB4o/DB4oManager.cs b/OpenGrid.Framework.Data.DB4o/DB4oManager.cs index eb93313c9d..aaa6e916be 100644 --- a/OpenGrid.Framework.Data.DB4o/DB4oManager.cs +++ b/OpenGrid.Framework.Data.DB4o/DB4oManager.cs @@ -57,12 +57,12 @@ namespace OpenGrid.Framework.Data.DB4o } - class DB4oGridManager + class DB4oUserManager { public Dictionary userProfiles = new Dictionary(); string dbfl; - public DB4oGridManager(string db4odb) + public DB4oUserManager(string db4odb) { dbfl = db4odb; IObjectContainer database; diff --git a/OpenGrid.Framework.Data.DB4o/DB4oUserData.cs b/OpenGrid.Framework.Data.DB4o/DB4oUserData.cs index c2f2db12b8..c21d7e22d2 100644 --- a/OpenGrid.Framework.Data.DB4o/DB4oUserData.cs +++ b/OpenGrid.Framework.Data.DB4o/DB4oUserData.cs @@ -8,34 +8,57 @@ namespace OpenGrid.Framework.Data.DB4o { public class DB4oUserData : IUserData { + DB4oUserManager manager = new DB4oUserManager("userprofiles.yap"); + public UserProfileData getUserByUUID(LLUUID uuid) { - return new UserProfileData(); + if(manager.userProfiles.ContainsKey(uuid)) + return manager.userProfiles[uuid]; + return null; } public UserProfileData getUserByName(string name) { - return getUserByName(name.Split(',')[0], name.Split(',')[1]); + return getUserByName(name.Split(' ')[0], name.Split(' ')[1]); } public UserProfileData getUserByName(string fname, string lname) { - return new UserProfileData(); + foreach (UserProfileData profile in manager.userProfiles.Values) + { + if (profile.username == fname && profile.surname == lname) + return profile; + } + return null; } public UserAgentData getAgentByUUID(LLUUID uuid) { - return new UserAgentData(); + try + { + return getUserByUUID(uuid).currentAgent; + } + catch (Exception e) + { + return null; + } } public UserAgentData getAgentByName(string name) { - return getAgentByName(name.Split(',')[0], name.Split(',')[1]); + return getAgentByName(name.Split(' ')[0], name.Split(' ')[1]); } public UserAgentData getAgentByName(string fname, string lname) { - return new UserAgentData(); + try + { + return getUserByName(fname,lname).currentAgent; + } + catch (Exception e) + { + return null; + } } public bool moneyTransferRequest(LLUUID from, LLUUID to, uint amount) diff --git a/OpenGrid.Framework.Data/UserProfileData.cs b/OpenGrid.Framework.Data/UserProfileData.cs index ad5b5b8a7d..3a5482889f 100644 --- a/OpenGrid.Framework.Data/UserProfileData.cs +++ b/OpenGrid.Framework.Data/UserProfileData.cs @@ -7,29 +7,30 @@ namespace OpenGrid.Framework.Data { public class UserProfileData { - string username; // The configurable part of the users username - string surname; // The users surname (can be used to indicate user class - eg 'Test User' or 'Test Admin') + public LLUUID UUID; + public string username; // The configurable part of the users username + public string surname; // The users surname (can be used to indicate user class - eg 'Test User' or 'Test Admin') - string passwordHash; // Hash of the users password + public string passwordHash; // Hash of the users password - ulong homeRegion; // RegionHandle of home - LLVector3 homeLocation; // Home Location inside the sim + public ulong homeRegion; // RegionHandle of home + public LLVector3 homeLocation; // Home Location inside the sim - int created; // UNIX Epoch Timestamp (User Creation) - int lastLogin; // UNIX Epoch Timestamp (Last Login Time) + public int created; // UNIX Epoch Timestamp (User Creation) + public int lastLogin; // UNIX Epoch Timestamp (Last Login Time) - string userInventoryURI; // URI to inventory server for this user - string userAssetURI; // URI to asset server for this user + public string userInventoryURI; // URI to inventory server for this user + public string userAssetURI; // URI to asset server for this user - uint profileCanDoMask; // Profile window "I can do" mask - uint profileWantDoMask; // Profile window "I want to" mask + public uint profileCanDoMask; // Profile window "I can do" mask + public uint profileWantDoMask; // Profile window "I want to" mask - string profileAboutText; // My about window text - string profileFirstText; // First Life Text + public string profileAboutText; // My about window text + public string profileFirstText; // First Life Text - LLUUID profileImage; // My avatars profile image - LLUUID profileFirstImage; // First-life image - UserAgentData currentAgent; // The users last agent + public LLUUID profileImage; // My avatars profile image + public LLUUID profileFirstImage; // First-life image + public UserAgentData currentAgent; // The users last agent } public class UserAgentData