More formatting cleanup. Minor refactoring.

0.6.0-stable
Jeff Ames 2008-05-14 06:09:39 +00:00
parent 39eb39c0d5
commit b7a0855c3a
9 changed files with 219 additions and 110 deletions

View File

@ -60,7 +60,8 @@ namespace OpenSim.Data.NHibernate
// Split out the dialect, driver, and connect string
char[] split = {';'};
string[] parts = connect.Split(split, 3);
if (parts.Length != 3) {
if (parts.Length != 3)
{
// TODO: make this a real exception type
throw new Exception("Malformed Inventory connection string '" + connect + "'");
}
@ -96,15 +97,22 @@ namespace OpenSim.Data.NHibernate
{
string regex = @"no such table: Assets";
Regex RE = new Regex(regex, RegexOptions.Multiline);
try {
using (ISession session = factory.OpenSession()) {
try
{
using (ISession session = factory.OpenSession())
{
session.Load(typeof(AssetBase), LLUUID.Zero);
}
} catch (ObjectNotFoundException) {
}
catch (ObjectNotFoundException)
{
// yes, we know it's not there, but that's ok
} catch (ADOException e) {
}
catch (ADOException e)
{
Match m = RE.Match(e.ToString());
if (m.Success) {
if (m.Success)
{
// We don't have this table, so create it.
new SchemaExport(cfg).Create(true, true);
}
@ -113,10 +121,14 @@ namespace OpenSim.Data.NHibernate
override public AssetBase FetchAsset(LLUUID uuid)
{
using (ISession session = factory.OpenSession()) {
try {
using (ISession session = factory.OpenSession())
{
try
{
return session.Load(typeof(AssetBase), uuid) as AssetBase;
} catch {
}
catch
{
return null;
}
}
@ -124,9 +136,12 @@ namespace OpenSim.Data.NHibernate
override public void CreateAsset(AssetBase asset)
{
if (!ExistsAsset(asset.FullID)) {
using (ISession session = factory.OpenSession()) {
using (ITransaction transaction = session.BeginTransaction()) {
if (!ExistsAsset(asset.FullID))
{
using (ISession session = factory.OpenSession())
{
using (ITransaction transaction = session.BeginTransaction())
{
session.Save(asset);
transaction.Commit();
}
@ -136,9 +151,12 @@ namespace OpenSim.Data.NHibernate
override public void UpdateAsset(AssetBase asset)
{
if (ExistsAsset(asset.FullID)) {
using (ISession session = factory.OpenSession()) {
using (ITransaction transaction = session.BeginTransaction()) {
if (ExistsAsset(asset.FullID))
{
using (ISession session = factory.OpenSession())
{
using (ITransaction transaction = session.BeginTransaction())
{
session.Update(asset);
transaction.Commit();
}

View File

@ -57,7 +57,8 @@ namespace OpenSim.Data.NHibernate
// Split out the dialect, driver, and connect string
char[] split = {';'};
string[] parts = connect.Split(split, 3);
if (parts.Length != 3) {
if (parts.Length != 3)
{
// TODO: make this a real exception type
throw new Exception("Malformed Inventory connection string '" + connect + "'");
}
@ -94,15 +95,22 @@ namespace OpenSim.Data.NHibernate
{
string regex = @"no such table: Inventory";
Regex RE = new Regex(regex, RegexOptions.Multiline);
try {
using (ISession session = factory.OpenSession()) {
try
{
using (ISession session = factory.OpenSession())
{
session.Load(typeof(InventoryItemBase), LLUUID.Zero);
}
} catch (ObjectNotFoundException) {
}
catch (ObjectNotFoundException)
{
// yes, we know it's not there, but that's ok
} catch (ADOException e) {
}
catch (ADOException e)
{
Match m = RE.Match(e.ToString());
if (m.Success) {
if (m.Success)
{
// We don't have this table, so create it.
new SchemaExport(cfg).Create(true, true);
}
@ -125,10 +133,14 @@ namespace OpenSim.Data.NHibernate
/// <returns>A class containing item information</returns>
public InventoryItemBase getInventoryItem(LLUUID item)
{
using (ISession session = factory.OpenSession()) {
try {
using (ISession session = factory.OpenSession())
{
try
{
return session.Load(typeof(InventoryItemBase), item) as InventoryItemBase;
} catch {
}
catch
{
m_log.ErrorFormat("Couldn't find inventory item: {0}", item);
return null;
}
@ -141,14 +153,19 @@ namespace OpenSim.Data.NHibernate
/// <param name="item">The item to be created</param>
public void addInventoryItem(InventoryItemBase item)
{
if (!ExistsItem(item.ID)) {
using (ISession session = factory.OpenSession()) {
using (ITransaction transaction = session.BeginTransaction()) {
if (!ExistsItem(item.ID))
{
using (ISession session = factory.OpenSession())
{
using (ITransaction transaction = session.BeginTransaction())
{
session.Save(item);
transaction.Commit();
}
}
} else {
}
else
{
m_log.ErrorFormat("Attempted to add Inventory Item {0} that already exists, updating instead", item.ID);
updateInventoryItem(item);
}
@ -160,14 +177,19 @@ namespace OpenSim.Data.NHibernate
/// <param name="item">The updated item</param>
public void updateInventoryItem(InventoryItemBase item)
{
if (ExistsItem(item.ID)) {
using (ISession session = factory.OpenSession()) {
using (ITransaction transaction = session.BeginTransaction()) {
if (ExistsItem(item.ID))
{
using (ISession session = factory.OpenSession())
{
using (ITransaction transaction = session.BeginTransaction())
{
session.Update(item);
transaction.Commit();
}
}
} else {
}
else
{
m_log.ErrorFormat("Attempted to add Inventory Item {0} that already exists", item.ID);
}
}
@ -178,15 +200,16 @@ namespace OpenSim.Data.NHibernate
/// <param name="item"></param>
public void deleteInventoryItem(LLUUID itemID)
{
using (ISession session = factory.OpenSession()) {
using (ITransaction transaction = session.BeginTransaction()) {
using (ISession session = factory.OpenSession())
{
using (ITransaction transaction = session.BeginTransaction())
{
session.Delete(itemID);
transaction.Commit();
}
}
}
/// <summary>
/// Returns an inventory folder by its UUID
/// </summary>
@ -194,10 +217,14 @@ namespace OpenSim.Data.NHibernate
/// <returns>A class containing folder information</returns>
public InventoryFolderBase getInventoryFolder(LLUUID folder)
{
using (ISession session = factory.OpenSession()) {
try {
using (ISession session = factory.OpenSession())
{
try
{
return session.Load(typeof(InventoryFolderBase), folder) as InventoryFolderBase;
} catch {
}
catch
{
m_log.ErrorFormat("Couldn't find inventory item: {0}", folder);
return null;
}
@ -210,14 +237,19 @@ namespace OpenSim.Data.NHibernate
/// <param name="folder">The folder to be created</param>
public void addInventoryFolder(InventoryFolderBase folder)
{
if (!ExistsFolder(folder.ID)) {
using (ISession session = factory.OpenSession()) {
using (ITransaction transaction = session.BeginTransaction()) {
if (!ExistsFolder(folder.ID))
{
using (ISession session = factory.OpenSession())
{
using (ITransaction transaction = session.BeginTransaction())
{
session.Save(folder);
transaction.Commit();
}
}
} else {
}
else
{
m_log.ErrorFormat("Attempted to add Inventory Folder {0} that already exists, updating instead", folder.ID);
updateInventoryFolder(folder);
}
@ -229,14 +261,19 @@ namespace OpenSim.Data.NHibernate
/// <param name="folder">The updated folder</param>
public void updateInventoryFolder(InventoryFolderBase folder)
{
if (ExistsFolder(folder.ID)) {
using (ISession session = factory.OpenSession()) {
using (ITransaction transaction = session.BeginTransaction()) {
if (ExistsFolder(folder.ID))
{
using (ISession session = factory.OpenSession())
{
using (ITransaction transaction = session.BeginTransaction())
{
session.Update(folder);
transaction.Commit();
}
}
} else {
}
else
{
m_log.ErrorFormat("Attempted to add Inventory Folder {0} that already exists", folder.ID);
}
}
@ -247,8 +284,10 @@ namespace OpenSim.Data.NHibernate
/// <param name="folder"></param>
public void deleteInventoryFolder(LLUUID folderID)
{
using (ISession session = factory.OpenSession()) {
using (ITransaction transaction = session.BeginTransaction()) {
using (ISession session = factory.OpenSession())
{
using (ITransaction transaction = session.BeginTransaction())
{
session.Delete(folderID.ToString());
transaction.Commit();
}
@ -324,7 +363,8 @@ namespace OpenSim.Data.NHibernate
/// <returns>A List of InventoryItemBase items</returns>
public List<InventoryItemBase> getInventoryInFolder(LLUUID folderID)
{
using (ISession session = factory.OpenSession()) {
using (ISession session = factory.OpenSession())
{
// try {
ICriteria criteria = session.CreateCriteria(typeof(InventoryItemBase));
criteria.Add(Expression.Eq("Folder", folderID));
@ -334,7 +374,9 @@ namespace OpenSim.Data.NHibernate
list.Add(item);
}
return list;
// } catch {
// }
// catch
// {
// return new List<InventoryItemBase>();
// }
}
@ -348,8 +390,10 @@ namespace OpenSim.Data.NHibernate
// see InventoryItemBase.getUserRootFolder
public InventoryFolderBase getUserRootFolder(LLUUID user)
{
using (ISession session = factory.OpenSession()) {
// try {
using (ISession session = factory.OpenSession())
{
// try
// {
ICriteria criteria = session.CreateCriteria(typeof(InventoryFolderBase));
criteria.Add(Expression.Eq("ParentID", LLUUID.Zero));
criteria.Add(Expression.Eq("Owner", user));
@ -359,7 +403,9 @@ namespace OpenSim.Data.NHibernate
}
m_log.ErrorFormat("No Inventory Root Folder Found for: {0}", user);
return new InventoryFolderBase();
// } catch {
// }
// catch
// {
// return new InventoryFolderBase();
// }
}
@ -372,15 +418,19 @@ namespace OpenSim.Data.NHibernate
/// <param name="parentID">ID of parent</param>
private void getInventoryFolders(ref List<InventoryFolderBase> folders, LLUUID parentID)
{
using (ISession session = factory.OpenSession()) {
// try {
using (ISession session = factory.OpenSession())
{
// try
// {
ICriteria criteria = session.CreateCriteria(typeof(InventoryFolderBase));
criteria.Add(Expression.Eq("ParentID", parentID));
foreach (InventoryFolderBase item in criteria.List())
{
folders.Add(item);
}
// } catch {
// }
// catch
// {
// m_log.ErrorFormat("Can't run getInventoryFolders for Folder ID: {0}", parentID);
// }
}

View File

@ -56,7 +56,8 @@ namespace OpenSim.Data.NHibernate
{
char[] split = {';'};
string[] parts = connect.Split(split, 3);
if (parts.Length != 3) {
if (parts.Length != 3)
{
// TODO: make this a real exception type
throw new Exception("Malformed Inventory connection string '" + connect + "'");
}
@ -87,15 +88,22 @@ namespace OpenSim.Data.NHibernate
{
string regex = @"no such table: UserProfiles";
Regex RE = new Regex(regex, RegexOptions.Multiline);
try {
using (ISession session = factory.OpenSession()) {
try
{
using (ISession session = factory.OpenSession())
{
session.Load(typeof(UserProfileData), LLUUID.Zero);
}
} catch (ObjectNotFoundException) {
}
catch (ObjectNotFoundException)
{
// yes, we know it's not there, but that's ok
} catch (ADOException e) {
}
catch (ADOException e)
{
Match m = RE.Match(e.ToString());
if (m.Success) {
if (m.Success)
{
// We don't have this table, so create it.
new SchemaExport(cfg).Create(true, true);
}
@ -105,12 +113,15 @@ namespace OpenSim.Data.NHibernate
private bool ExistsUser(LLUUID uuid)
{
UserProfileData user = null;
try {
using (ISession session = factory.OpenSession()) {
try
{
using (ISession session = factory.OpenSession())
{
user = session.Load(typeof(UserProfileData), uuid) as UserProfileData;
}
// BUG: CATCHALL IS BAD.
} catch (Exception) {}
}
catch (Exception) {}
return (user != null);
}
@ -119,7 +130,8 @@ namespace OpenSim.Data.NHibernate
{
UserProfileData user;
// TODO: I'm sure I'll have to do something silly here
using (ISession session = factory.OpenSession()) {
using (ISession session = factory.OpenSession())
{
user = session.Load(typeof(UserProfileData), uuid) as UserProfileData;
user.CurrentAgent = GetAgentByUUID(uuid);
}
@ -128,16 +140,21 @@ namespace OpenSim.Data.NHibernate
override public void AddNewUserProfile(UserProfileData profile)
{
if (!ExistsUser(profile.ID)) {
using (ISession session = factory.OpenSession()) {
using (ITransaction transaction = session.BeginTransaction()) {
if (!ExistsUser(profile.ID))
{
using (ISession session = factory.OpenSession())
{
using (ITransaction transaction = session.BeginTransaction())
{
session.Save(profile);
SetAgentData(profile.ID, profile.CurrentAgent, session);
// TODO: save agent
transaction.Commit();
}
}
} else {
}
else
{
m_log.ErrorFormat("Attempted to add User {0} {1} that already exists, updating instead", profile.FirstName, profile.SurName);
UpdateUserProfile(profile);
}
@ -165,16 +182,21 @@ namespace OpenSim.Data.NHibernate
}
override public bool UpdateUserProfile(UserProfileData profile)
{
if (ExistsUser(profile.ID)) {
using (ISession session = factory.OpenSession()) {
using (ITransaction transaction = session.BeginTransaction()) {
if (ExistsUser(profile.ID))
{
using (ISession session = factory.OpenSession())
{
using (ITransaction transaction = session.BeginTransaction())
{
session.Update(profile);
SetAgentData(profile.ID, profile.CurrentAgent, session);
transaction.Commit();
return true;
}
}
} else {
}
else
{
m_log.ErrorFormat("Attempted to update User {0} {1} that doesn't exist, updating instead", profile.FirstName, profile.SurName);
AddNewUserProfile(profile);
return true;
@ -183,8 +205,10 @@ namespace OpenSim.Data.NHibernate
override public void AddNewUserAgent(UserAgentData agent)
{
using (ISession session = factory.OpenSession()) {
using (ITransaction transaction = session.BeginTransaction()) {
using (ISession session = factory.OpenSession())
{
using (ITransaction transaction = session.BeginTransaction())
{
session.Save(agent);
transaction.Commit();
}
@ -193,30 +217,35 @@ namespace OpenSim.Data.NHibernate
public void UpdateUserAgent(UserAgentData agent)
{
using (ISession session = factory.OpenSession()) {
using (ITransaction transaction = session.BeginTransaction()) {
using (ISession session = factory.OpenSession())
{
using (ITransaction transaction = session.BeginTransaction())
{
session.Update(agent);
transaction.Commit();
}
}
}
override public UserAgentData GetAgentByUUID(LLUUID uuid)
{
try {
using (ISession session = factory.OpenSession()) {
try
{
using (ISession session = factory.OpenSession())
{
return session.Load(typeof(UserAgentData), uuid) as UserAgentData;
}
} catch {
}
catch
{
return null;
}
}
override public UserProfileData GetUserByName(string fname, string lname)
{
using (ISession session = factory.OpenSession()) {
using (ISession session = factory.OpenSession())
{
ICriteria criteria = session.CreateCriteria(typeof(UserProfileData));
criteria.Add(Expression.Eq("FirstName", fname));
criteria.Add(Expression.Eq("SurName", lname));
@ -247,7 +276,8 @@ namespace OpenSim.Data.NHibernate
if (querysplit.Length == 2)
{
using (ISession session = factory.OpenSession()) {
using (ISession session = factory.OpenSession())
{
ICriteria criteria = session.CreateCriteria(typeof(UserProfileData));
criteria.Add(Expression.Like("FirstName", querysplit[0]));
criteria.Add(Expression.Like("SurName", querysplit[1]));
@ -280,7 +310,8 @@ namespace OpenSim.Data.NHibernate
{
UserAppearance appearance;
// TODO: I'm sure I'll have to do something silly here
using (ISession session = factory.OpenSession()) {
using (ISession session = factory.OpenSession())
{
appearance = session.Load(typeof(UserAppearance), user) as UserAppearance;
}
return appearance;
@ -289,7 +320,8 @@ namespace OpenSim.Data.NHibernate
private bool ExistsAppearance(LLUUID uuid)
{
UserAppearance appearance;
using (ISession session = factory.OpenSession()) {
using (ISession session = factory.OpenSession())
{
appearance = session.Load(typeof(UserAppearance), uuid) as UserAppearance;
}
return (appearance == null) ? false : true;
@ -299,11 +331,16 @@ namespace OpenSim.Data.NHibernate
override public void UpdateUserAppearance(LLUUID user, UserAppearance appearance)
{
bool exists = ExistsAppearance(user);
using (ISession session = factory.OpenSession()) {
using (ITransaction transaction = session.BeginTransaction()) {
if (exists) {
using (ISession session = factory.OpenSession())
{
using (ITransaction transaction = session.BeginTransaction())
{
if (exists)
{
session.Update(appearance);
} else {
}
else
{
session.Save(appearance);
}
transaction.Commit();

View File

@ -32,7 +32,7 @@ namespace OpenGridServices.Manager
{
public partial class MainWindow: Gtk.Window
{
public MainWindow (): base (Gtk.WindowType.Toplevel)
public MainWindow() : base (Gtk.WindowType.Toplevel)
{
Build();
}
@ -57,10 +57,13 @@ namespace OpenGridServices.Manager
public void SetGridServerConnected(bool connected)
{
if (connected) {
if (connected)
{
this.ConnectToGridserver.Visible=false;
this.DisconnectFromGridServer.Visible=true;
} else {
}
else
{
this.ConnectToGridserver.Visible=true;
this.DisconnectFromGridServer.Visible=false;
}

View File

@ -35,24 +35,29 @@
// {
// public float llSin() {
// public float llSin()
// {
// float f = (float)LSLStack.Pop();
// return LSL_Builtins.llSin(f);
// }
// public float llCos() {
// public float llCos()
// {
// float f = (float)LSLStack.Pop();
// return LSL_Builtins.llCos(f);
// }
// public float llTan() {
// public float llTan()
// {
// float f = (float)LSLStack.Pop();
// return LSL_Builtins.llTan(f);
// }
// public float llAtan2() {
// public float llAtan2()
// {
// float x = (float)LSLStack.Pop();
// float y = (float)LSLStack.Pop();
// return LSL_Builtins.llAtan2(x, y);
// }
// public float llSqrt() {
// public float llSqrt()
// {
// float f = (float)LSLStack.Pop();
// return LSL_Builtins.llSqrt(f);
// }

View File

@ -34,7 +34,8 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO
{
//public System.Collections.Generic.Dictionary<Byte, Type> OpCode_Add_Types;
//LSO_Enums() {
//LSO_Enums()
//{
// OpCode_Add_Types.Add(51, typeof(String));
// OpCode_Add_Types.Add(17, typeof(UInt32));
//}

View File

@ -163,7 +163,8 @@ namespace OpenSim.Grid.UserServer
theUser.CurrentAgent.Region = SimInfo.UUID;
theUser.CurrentAgent.Handle = SimInfo.regionHandle;
if (start_x >= 0 && start_y >= 0 && start_z >= 0) {
if (start_x >= 0 && start_y >= 0 && start_z >= 0)
{
LLVector3 tmp_v = new LLVector3(start_x, start_y, start_z);
theUser.CurrentAgent.Position = tmp_v;
}

View File

@ -745,13 +745,7 @@ namespace OpenSim
/// <param name="regionnum">The first out parameter describing the number of regions</param>
public void GetRegionNumber(out int regionnum)
{
int accounter = 0;
//List<string> regionNameList = new List<string>();
m_sceneManager.ForEachScene(delegate(Scene scene) {
accounter++;
});
regionnum = accounter;
regionnum = m_sceneManager.Scenes.Count;
}
}
}

View File

@ -147,7 +147,7 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer
foreach (ScenePresence pre in presences)
{
IClientAPI client = pre.ControllingClient;
//if (pre.MovementFlag!=0 && client.PacketProcessingEnabled==true) {
//if (pre.MovementFlag!=0 && client.PacketProcessingEnabled==true)
if (client.IsActive)
{
get_scene_presence_filter++;
@ -160,7 +160,7 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer
foreach (ScenePresence pre in avatars)
{
IClientAPI client = pre.ControllingClient;
//if (pre.MovementFlag!=0 && client.PacketProcessingEnabled==true) {
//if (pre.MovementFlag!=0 && client.PacketProcessingEnabled==true)
if (client.IsActive)
{
get_avatar_filter++;