From fdc9ed89b4adaa7f23ca06613b2ee36c30895021 Mon Sep 17 00:00:00 2001 From: MW Date: Mon, 2 Apr 2007 15:48:01 +0000 Subject: OpenSim no longer uses OpenSim.Config.SimConfigDb4o, it now uses OpenSim.GenericConfig.Xml (or a class implementing IGenericConfig). --- OpenSim.Framework/IGenericConfig.cs | 15 +++++++ OpenSim.Framework/UserProfileManagerBase.cs | 62 +++++++++++++++-------------- 2 files changed, 48 insertions(+), 29 deletions(-) create mode 100644 OpenSim.Framework/IGenericConfig.cs (limited to 'OpenSim.Framework') diff --git a/OpenSim.Framework/IGenericConfig.cs b/OpenSim.Framework/IGenericConfig.cs new file mode 100644 index 0000000..a853fe4 --- /dev/null +++ b/OpenSim.Framework/IGenericConfig.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Framework.Interfaces +{ + public interface IGenericConfig + { + void LoadData(); + string GetAttribute(string attributeName); + bool SetAttribute(string attributeName, string attributeValue); + void Commit(); + void Close(); + } +} diff --git a/OpenSim.Framework/UserProfileManagerBase.cs b/OpenSim.Framework/UserProfileManagerBase.cs index c022feb..4428831 100644 --- a/OpenSim.Framework/UserProfileManagerBase.cs +++ b/OpenSim.Framework/UserProfileManagerBase.cs @@ -13,36 +13,40 @@ namespace OpenSim.Framework.User public Dictionary UserProfiles = new Dictionary(); - public UserProfileManagerBase() { - } + public UserProfileManagerBase() + { + } public virtual void InitUserProfiles() { - IObjectContainer db; - db = Db4oFactory.OpenFile("userprofiles.yap"); - IObjectSet result = db.Get(typeof(UserProfile)); - foreach (UserProfile userprof in result) { - UserProfiles.Add(userprof.UUID, userprof); - } - Console.WriteLine("UserProfiles.Cs:InitUserProfiles() - Successfully loaded " + result.Count.ToString() + " from database"); - db.Close(); + IObjectContainer db; + db = Db4oFactory.OpenFile("userprofiles.yap"); + IObjectSet result = db.Get(typeof(UserProfile)); + foreach (UserProfile userprof in result) + { + UserProfiles.Add(userprof.UUID, userprof); + } + Console.WriteLine("UserProfiles.Cs:InitUserProfiles() - Successfully loaded " + result.Count.ToString() + " from database"); + db.Close(); } - public virtual void SaveUserProfiles() // ZOMG! INEFFICIENT! - { - IObjectContainer db; - db = Db4oFactory.OpenFile("userprofiles.yap"); - IObjectSet result = db.Get(typeof(UserProfile)); - foreach (UserProfile userprof in result) { - db.Delete(userprof); - db.Commit(); - } - foreach (UserProfile userprof in UserProfiles.Values) { - db.Set(userprof); - db.Commit(); - } - db.Close(); - } + public virtual void SaveUserProfiles() // ZOMG! INEFFICIENT! + { + IObjectContainer db; + db = Db4oFactory.OpenFile("userprofiles.yap"); + IObjectSet result = db.Get(typeof(UserProfile)); + foreach (UserProfile userprof in result) + { + db.Delete(userprof); + db.Commit(); + } + foreach (UserProfile userprof in UserProfiles.Values) + { + db.Set(userprof); + db.Commit(); + } + db.Close(); + } public UserProfile GetProfileByName(string firstname, string lastname) { @@ -74,13 +78,13 @@ namespace OpenSim.Framework.User } else { - Console.WriteLine("UserProfile - not authorised, password not match "+ TheUser.MD5passwd +" and "+ passwd); + Console.WriteLine("UserProfile - not authorised, password not match " + TheUser.MD5passwd + " and " + passwd); return false; } } else { - Console.WriteLine("UserProfile - not authorised , unkown: "+ firstname +" , " + lastname); + Console.WriteLine("UserProfile - not authorised , unkown: " + firstname + " , " + lastname); return false; } @@ -102,8 +106,8 @@ namespace OpenSim.Framework.User newprofile.UUID = LLUUID.Random(); newprofile.Inventory.CreateRootFolder(newprofile.UUID, true); this.UserProfiles.Add(newprofile.UUID, newprofile); - return newprofile; - } + return newprofile; + } public virtual AgentInventory GetUsersInventory(LLUUID agentID) { -- cgit v1.1