From 61397a34105e7aa8353fc661a497fc3d714b582f Mon Sep 17 00:00:00 2001
From: Sean Dague
Date: Sun, 21 Oct 2007 14:59:18 +0000
Subject: fix line ending mixing. Probably should put some wiki descriptions
up on line endings so we don't keep ending up in this place.
---
OpenSim/Framework/General/PolicyManager/ACL.cs | 446 +++++++++++------------
OpenSim/Region/Environment/Modules/ChatModule.cs | 248 ++++++-------
OpenSim/Region/Environment/PermissionManager.cs | 2 +-
3 files changed, 348 insertions(+), 348 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Framework/General/PolicyManager/ACL.cs b/OpenSim/Framework/General/PolicyManager/ACL.cs
index 4f357c4..53c1b2d 100644
--- a/OpenSim/Framework/General/PolicyManager/ACL.cs
+++ b/OpenSim/Framework/General/PolicyManager/ACL.cs
@@ -1,223 +1,223 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace OpenSim.Framework.PolicyManager
-{
- #region ACL Core Class
- ///
- /// Access Control List Engine
- ///
- public class ACL
- {
- Dictionary Roles = new Dictionary();
- Dictionary Resources = new Dictionary();
-
- public ACL AddRole(Role role)
- {
- if (Roles.ContainsKey(role.Name))
- throw new AlreadyContainsRoleException(role);
-
- Roles.Add(role.Name, role);
-
- return this;
- }
-
- public ACL AddResource(Resource resource)
- {
- Resources.Add(resource.Name, resource);
-
- return this;
- }
-
- public Permission HasPermission(string role, string resource)
- {
- if (!Roles.ContainsKey(role))
- throw new KeyNotFoundException();
-
- if (!Resources.ContainsKey(resource))
- throw new KeyNotFoundException();
-
- return Roles[role].RequestPermission(resource);
- }
-
- public ACL GrantPermission(string role, string resource)
- {
- if (!Roles.ContainsKey(role))
- throw new KeyNotFoundException();
-
- if (!Resources.ContainsKey(resource))
- throw new KeyNotFoundException();
-
- Roles[role].GivePermission(resource, Permission.Allow);
-
- return this;
- }
-
- public ACL DenyPermission(string role, string resource)
- {
- if (!Roles.ContainsKey(role))
- throw new KeyNotFoundException();
-
- if (!Resources.ContainsKey(resource))
- throw new KeyNotFoundException();
-
- Roles[role].GivePermission(resource, Permission.Deny);
-
- return this;
- }
-
- public ACL ResetPermission(string role, string resource)
- {
- if (!Roles.ContainsKey(role))
- throw new KeyNotFoundException();
-
- if (!Resources.ContainsKey(resource))
- throw new KeyNotFoundException();
-
- Roles[role].GivePermission(resource, Permission.None);
-
- return this;
- }
- }
- #endregion
-
- #region Exceptions
- ///
- /// Thrown when an ACL attempts to add a duplicate role.
- ///
- public class AlreadyContainsRoleException : Exception
- {
- protected Role m_role;
-
- public Role ErrorRole
- {
- get { return m_role; }
- }
-
- public AlreadyContainsRoleException(Role role)
- {
- m_role = role;
- }
-
- public override string ToString()
- {
- return "This ACL already contains a role called '" + m_role.Name + "'.";
- }
- }
- #endregion
-
- #region Roles and Resources
-
- ///
- /// Does this Role have permission to access a specified Resource?
- ///
- public enum Permission { Deny, None, Allow };
-
- ///
- /// A role class, for use with Users or Groups
- ///
- public class Role
- {
- private string m_name;
- private Role[] m_parents;
- private Dictionary m_resources = new Dictionary();
-
- public string Name
- {
- get { return m_name; }
- }
-
- public Permission RequestPermission(string resource)
- {
- return RequestPermission(resource, Permission.None);
- }
-
- public Permission RequestPermission(string resource, Permission current)
- {
- // Deny permissions always override any others
- if (current == Permission.Deny)
- return current;
-
- Permission temp = Permission.None;
-
- // Pickup non-None permissions
- if (m_resources.ContainsKey(resource) && m_resources[resource] != Permission.None)
- temp = m_resources[resource];
-
- if (m_parents != null)
- {
- foreach (Role parent in m_parents)
- {
- temp = parent.RequestPermission(resource, temp);
- }
- }
-
- return temp;
- }
-
- public void GivePermission(string resource, Permission perm)
- {
- m_resources[resource] = perm;
- }
-
- public Role(string name)
- {
- m_name = name;
- m_parents = null;
- }
-
- public Role(string name, Role[] parents)
- {
- m_name = name;
- m_parents = parents;
- }
- }
-
- public class Resource
- {
- private string m_name;
-
- public string Name
- {
- get { return m_name; }
- }
-
- public Resource(string name)
- {
- m_name = name;
- }
- }
-
- #endregion
-
- #region Tests
-
- class ACLTester
- {
- public ACLTester()
- {
- ACL acl = new ACL();
-
- Role Guests = new Role("Guests");
- acl.AddRole(Guests);
-
- Role[] parents = new Role[0];
- parents[0] = Guests;
-
- Role JoeGuest = new Role("JoeGuest", parents);
- acl.AddRole(JoeGuest);
-
- Resource CanBuild = new Resource("CanBuild");
- acl.AddResource(CanBuild);
-
-
- acl.GrantPermission("Guests", "CanBuild");
-
- acl.HasPermission("JoeGuest", "CanBuild");
-
- }
- }
-
- #endregion
-}
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace OpenSim.Framework.PolicyManager
+{
+ #region ACL Core Class
+ ///
+ /// Access Control List Engine
+ ///
+ public class ACL
+ {
+ Dictionary Roles = new Dictionary();
+ Dictionary Resources = new Dictionary();
+
+ public ACL AddRole(Role role)
+ {
+ if (Roles.ContainsKey(role.Name))
+ throw new AlreadyContainsRoleException(role);
+
+ Roles.Add(role.Name, role);
+
+ return this;
+ }
+
+ public ACL AddResource(Resource resource)
+ {
+ Resources.Add(resource.Name, resource);
+
+ return this;
+ }
+
+ public Permission HasPermission(string role, string resource)
+ {
+ if (!Roles.ContainsKey(role))
+ throw new KeyNotFoundException();
+
+ if (!Resources.ContainsKey(resource))
+ throw new KeyNotFoundException();
+
+ return Roles[role].RequestPermission(resource);
+ }
+
+ public ACL GrantPermission(string role, string resource)
+ {
+ if (!Roles.ContainsKey(role))
+ throw new KeyNotFoundException();
+
+ if (!Resources.ContainsKey(resource))
+ throw new KeyNotFoundException();
+
+ Roles[role].GivePermission(resource, Permission.Allow);
+
+ return this;
+ }
+
+ public ACL DenyPermission(string role, string resource)
+ {
+ if (!Roles.ContainsKey(role))
+ throw new KeyNotFoundException();
+
+ if (!Resources.ContainsKey(resource))
+ throw new KeyNotFoundException();
+
+ Roles[role].GivePermission(resource, Permission.Deny);
+
+ return this;
+ }
+
+ public ACL ResetPermission(string role, string resource)
+ {
+ if (!Roles.ContainsKey(role))
+ throw new KeyNotFoundException();
+
+ if (!Resources.ContainsKey(resource))
+ throw new KeyNotFoundException();
+
+ Roles[role].GivePermission(resource, Permission.None);
+
+ return this;
+ }
+ }
+ #endregion
+
+ #region Exceptions
+ ///
+ /// Thrown when an ACL attempts to add a duplicate role.
+ ///
+ public class AlreadyContainsRoleException : Exception
+ {
+ protected Role m_role;
+
+ public Role ErrorRole
+ {
+ get { return m_role; }
+ }
+
+ public AlreadyContainsRoleException(Role role)
+ {
+ m_role = role;
+ }
+
+ public override string ToString()
+ {
+ return "This ACL already contains a role called '" + m_role.Name + "'.";
+ }
+ }
+ #endregion
+
+ #region Roles and Resources
+
+ ///
+ /// Does this Role have permission to access a specified Resource?
+ ///
+ public enum Permission { Deny, None, Allow };
+
+ ///
+ /// A role class, for use with Users or Groups
+ ///
+ public class Role
+ {
+ private string m_name;
+ private Role[] m_parents;
+ private Dictionary m_resources = new Dictionary();
+
+ public string Name
+ {
+ get { return m_name; }
+ }
+
+ public Permission RequestPermission(string resource)
+ {
+ return RequestPermission(resource, Permission.None);
+ }
+
+ public Permission RequestPermission(string resource, Permission current)
+ {
+ // Deny permissions always override any others
+ if (current == Permission.Deny)
+ return current;
+
+ Permission temp = Permission.None;
+
+ // Pickup non-None permissions
+ if (m_resources.ContainsKey(resource) && m_resources[resource] != Permission.None)
+ temp = m_resources[resource];
+
+ if (m_parents != null)
+ {
+ foreach (Role parent in m_parents)
+ {
+ temp = parent.RequestPermission(resource, temp);
+ }
+ }
+
+ return temp;
+ }
+
+ public void GivePermission(string resource, Permission perm)
+ {
+ m_resources[resource] = perm;
+ }
+
+ public Role(string name)
+ {
+ m_name = name;
+ m_parents = null;
+ }
+
+ public Role(string name, Role[] parents)
+ {
+ m_name = name;
+ m_parents = parents;
+ }
+ }
+
+ public class Resource
+ {
+ private string m_name;
+
+ public string Name
+ {
+ get { return m_name; }
+ }
+
+ public Resource(string name)
+ {
+ m_name = name;
+ }
+ }
+
+ #endregion
+
+ #region Tests
+
+ class ACLTester
+ {
+ public ACLTester()
+ {
+ ACL acl = new ACL();
+
+ Role Guests = new Role("Guests");
+ acl.AddRole(Guests);
+
+ Role[] parents = new Role[0];
+ parents[0] = Guests;
+
+ Role JoeGuest = new Role("JoeGuest", parents);
+ acl.AddRole(JoeGuest);
+
+ Resource CanBuild = new Resource("CanBuild");
+ acl.AddResource(CanBuild);
+
+
+ acl.GrantPermission("Guests", "CanBuild");
+
+ acl.HasPermission("JoeGuest", "CanBuild");
+
+ }
+ }
+
+ #endregion
+}
diff --git a/OpenSim/Region/Environment/Modules/ChatModule.cs b/OpenSim/Region/Environment/Modules/ChatModule.cs
index e1a591b..77e038f 100644
--- a/OpenSim/Region/Environment/Modules/ChatModule.cs
+++ b/OpenSim/Region/Environment/Modules/ChatModule.cs
@@ -41,18 +41,18 @@ using OpenSim.Region.Environment.Scenes;
namespace OpenSim.Region.Environment.Modules
{
public class ChatModule : IRegionModule, ISimChat
- {
- private List m_scenes = new List();
+ {
+ private List m_scenes = new List();
private LogBase m_log;
private string m_server = null;
private int m_port = 6668;
private string m_user = "USER OpenSimBot 8 * :I'm a OpenSim to irc bot";
private string m_nick = null;
- private string m_channel = null;
-
- private int m_whisperdistance = 10;
- private int m_saydistance = 30;
+ private string m_channel = null;
+
+ private int m_whisperdistance = 10;
+ private int m_saydistance = 30;
private int m_shoutdistance = 100;
private NetworkStream m_stream;
@@ -71,8 +71,8 @@ namespace OpenSim.Region.Environment.Modules
m_nick = "OSimBot" + Util.RandomClass.Next(1, 99);
m_irc = null;
m_ircWriter = null;
- m_ircReader = null;
-
+ m_ircReader = null;
+
m_log = OpenSim.Framework.Console.MainLog.Instance;
}
@@ -89,17 +89,17 @@ namespace OpenSim.Region.Environment.Modules
}
} catch (Exception e) {
Console.WriteLine("No IRC config information, skipping IRC bridge configuration");
- }
-
- m_whisperdistance = config.Configs["Chat"].GetInt("whisper_distance");
- m_saydistance = config.Configs["Chat"].GetInt("say_distance");
- m_shoutdistance = config.Configs["Chat"].GetInt("shout_distance");
-
- if (!m_scenes.Contains(scene))
- {
- m_scenes.Add(scene);
- scene.EventManager.OnNewClient += NewClient;
- scene.RegisterModuleInterface(this);
+ }
+
+ m_whisperdistance = config.Configs["Chat"].GetInt("whisper_distance");
+ m_saydistance = config.Configs["Chat"].GetInt("say_distance");
+ m_shoutdistance = config.Configs["Chat"].GetInt("shout_distance");
+
+ if (!m_scenes.Contains(scene))
+ {
+ m_scenes.Add(scene);
+ scene.EventManager.OnNewClient += NewClient;
+ scene.RegisterModuleInterface(this);
}
}
@@ -177,18 +177,18 @@ namespace OpenSim.Region.Environment.Modules
Console.WriteLine(inputLine);
if (inputLine.Contains(m_channel))
{
- string mess = inputLine.Substring(inputLine.IndexOf(m_channel));
- foreach (Scene m_scene in m_scenes)
- {
- m_scene.Broadcast(delegate(IClientAPI client)
- {
- client.SendChatMessage(
- Helpers.StringToField(mess), 255, pos, "IRC:",
- LLUUID.Zero);
- });
+ string mess = inputLine.Substring(inputLine.IndexOf(m_channel));
+ foreach (Scene m_scene in m_scenes)
+ {
+ m_scene.Broadcast(delegate(IClientAPI client)
+ {
+ client.SendChatMessage(
+ Helpers.StringToField(mess), 255, pos, "IRC:",
+ LLUUID.Zero);
+ });
}
}
- }
+ }
Thread.Sleep(50);
}
}
@@ -205,7 +205,7 @@ namespace OpenSim.Region.Environment.Modules
scene = m_scenes[0];
// Filled in since it's easier than rewriting right now.
- LLVector3 fromPos = e.Position;
+ LLVector3 fromPos = e.Position;
LLVector3 fromRegionPos = e.Position + new LLVector3(e.Scene.RegionInfo.RegionLocX * 256, e.Scene.RegionInfo.RegionLocY * 256, 0);
string fromName = e.From;
string message = e.Message;
@@ -217,108 +217,108 @@ namespace OpenSim.Region.Environment.Modules
if (avatar != null)
{
- fromPos = avatar.AbsolutePosition;
+ fromPos = avatar.AbsolutePosition;
fromRegionPos = fromPos + new LLVector3(e.Scene.RegionInfo.RegionLocX * 256, e.Scene.RegionInfo.RegionLocY * 256, 0);
fromName = avatar.Firstname + " " + avatar.Lastname;
fromAgentID = e.Sender.AgentId;
avatar = null;
- }
-
- string typeName;
- switch (e.Type)
- {
- case ChatTypeEnum.Broadcast:
- typeName = "broadcasts";
- break;
- case ChatTypeEnum.Say:
- typeName = "says";
- break;
- case ChatTypeEnum.Shout:
- typeName = "shouts";
- break;
- case ChatTypeEnum.Whisper:
- typeName = "whispers";
- break;
- default:
- typeName = "unknown";
- break;
- }
-
+ }
+
+ string typeName;
+ switch (e.Type)
+ {
+ case ChatTypeEnum.Broadcast:
+ typeName = "broadcasts";
+ break;
+ case ChatTypeEnum.Say:
+ typeName = "says";
+ break;
+ case ChatTypeEnum.Shout:
+ typeName = "shouts";
+ break;
+ case ChatTypeEnum.Whisper:
+ typeName = "whispers";
+ break;
+ default:
+ typeName = "unknown";
+ break;
+ }
+
m_log.Verbose("CHAT", fromName + " (" + e.Channel + " @ " + scene.RegionInfo.RegionName + ") " + typeName + ": " + e.Message);
if (connected)
- {
- try
- {
- m_ircWriter.WriteLine("PRIVMSG " + m_channel + " :" + "<" + fromName + " in " + scene.RegionInfo.RegionName + ">: " +
- e.Message);
- m_ircWriter.Flush();
- }
- catch (IOException)
- {
- m_log.Error("IRC","Disconnected from IRC server.");
- listener.Abort();
- pingSender.Abort();
- connected = false;
+ {
+ try
+ {
+ m_ircWriter.WriteLine("PRIVMSG " + m_channel + " :" + "<" + fromName + " in " + scene.RegionInfo.RegionName + ">: " +
+ e.Message);
+ m_ircWriter.Flush();
+ }
+ catch (IOException)
+ {
+ m_log.Error("IRC","Disconnected from IRC server.");
+ listener.Abort();
+ pingSender.Abort();
+ connected = false;
+ }
+ }
+
+ if (e.Channel == 0)
+ {
+ foreach (Scene m_scene in m_scenes)
+ {
+ m_scene.ForEachScenePresence(delegate(ScenePresence presence)
+ {
+ int dis = -100000;
+
+ LLVector3 avatarRegionPos = presence.AbsolutePosition + new LLVector3(scene.RegionInfo.RegionLocX * 256, scene.RegionInfo.RegionLocY * 256, 0);
+ dis = Math.Abs((int)avatarRegionPos.GetDistanceTo(fromRegionPos));
+
+ switch (e.Type)
+ {
+ case ChatTypeEnum.Whisper:
+ if (dis < m_whisperdistance)
+ {
+ //should change so the message is sent through the avatar rather than direct to the ClientView
+ presence.ControllingClient.SendChatMessage(message,
+ type,
+ fromPos,
+ fromName,
+ fromAgentID);
+ }
+ break;
+ default:
+ case ChatTypeEnum.Say:
+ if (dis < m_saydistance)
+ {
+ //Console.WriteLine("sending chat");
+ presence.ControllingClient.SendChatMessage(message,
+ type,
+ fromPos,
+ fromName,
+ fromAgentID);
+ }
+ break;
+ case ChatTypeEnum.Shout:
+ if (dis < m_shoutdistance)
+ {
+ presence.ControllingClient.SendChatMessage(message,
+ type,
+ fromPos,
+ fromName,
+ fromAgentID);
+ }
+ break;
+
+ case ChatTypeEnum.Broadcast:
+ presence.ControllingClient.SendChatMessage(message, type,
+ fromPos,
+ fromName,
+ fromAgentID);
+ break;
+ }
+ });
}
- }
-
- if (e.Channel == 0)
- {
- foreach (Scene m_scene in m_scenes)
- {
- m_scene.ForEachScenePresence(delegate(ScenePresence presence)
- {
- int dis = -100000;
-
- LLVector3 avatarRegionPos = presence.AbsolutePosition + new LLVector3(scene.RegionInfo.RegionLocX * 256, scene.RegionInfo.RegionLocY * 256, 0);
- dis = Math.Abs((int)avatarRegionPos.GetDistanceTo(fromRegionPos));
-
- switch (e.Type)
- {
- case ChatTypeEnum.Whisper:
- if (dis < m_whisperdistance)
- {
- //should change so the message is sent through the avatar rather than direct to the ClientView
- presence.ControllingClient.SendChatMessage(message,
- type,
- fromPos,
- fromName,
- fromAgentID);
- }
- break;
- default:
- case ChatTypeEnum.Say:
- if (dis < m_saydistance)
- {
- //Console.WriteLine("sending chat");
- presence.ControllingClient.SendChatMessage(message,
- type,
- fromPos,
- fromName,
- fromAgentID);
- }
- break;
- case ChatTypeEnum.Shout:
- if (dis < m_shoutdistance)
- {
- presence.ControllingClient.SendChatMessage(message,
- type,
- fromPos,
- fromName,
- fromAgentID);
- }
- break;
-
- case ChatTypeEnum.Broadcast:
- presence.ControllingClient.SendChatMessage(message, type,
- fromPos,
- fromName,
- fromAgentID);
- break;
- }
- });
- }
}
}
}
diff --git a/OpenSim/Region/Environment/PermissionManager.cs b/OpenSim/Region/Environment/PermissionManager.cs
index c856d57..d32ac0b 100644
--- a/OpenSim/Region/Environment/PermissionManager.cs
+++ b/OpenSim/Region/Environment/PermissionManager.cs
@@ -28,7 +28,7 @@
using libsecondlife;
using OpenSim.Region.Environment.LandManagement;
-using OpenSim.Region.Environment.Scenes;
+using OpenSim.Region.Environment.Scenes;
namespace OpenSim.Region.Environment
{
--
cgit v1.1