- a couple of minor code cleanups in RestInventoryServices

- cleanups and more comments in ChatModule and IRCBridgeModule
- adding Name support in ScenePresence
0.6.0-stable
Dr Scofield 2008-09-30 16:14:09 +00:00
parent 57a862bc01
commit 63b2e3575a
4 changed files with 93 additions and 80 deletions

View File

@ -1287,31 +1287,31 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
Rest.Log.DebugFormat("{0} Item : {1} {2} {3} Type = {4}, AssetType = {5}", Rest.Log.DebugFormat("{0} Item : {1} {2} {3} Type = {4}, AssetType = {5}",
MsgId, i.ID, indent, i.Name, i.InvType, i.AssetType); MsgId, i.ID, indent, i.Name, i.InvType, i.AssetType);
rdata.writer.WriteStartElement(String.Empty,"Item",String.Empty); rdata.writer.WriteStartElement(String.Empty, "Item", String.Empty);
rdata.writer.WriteAttributeString("name",String.Empty,i.Name); rdata.writer.WriteAttributeString("name", String.Empty, i.Name);
rdata.writer.WriteAttributeString("desc",String.Empty,i.Description); rdata.writer.WriteAttributeString("desc", String.Empty, i.Description);
rdata.writer.WriteAttributeString("uuid",String.Empty,i.ID.ToString()); rdata.writer.WriteAttributeString("uuid", String.Empty, i.ID.ToString());
rdata.writer.WriteAttributeString("folder",String.Empty,i.Folder.ToString()); rdata.writer.WriteAttributeString("folder", String.Empty, i.Folder.ToString());
rdata.writer.WriteAttributeString("owner",String.Empty,i.Owner.ToString()); rdata.writer.WriteAttributeString("owner", String.Empty, i.Owner.ToString());
rdata.writer.WriteAttributeString("creator",String.Empty,i.Creator.ToString()); rdata.writer.WriteAttributeString("creator", String.Empty, i.Creator.ToString());
rdata.writer.WriteAttributeString("creationdate",String.Empty,i.CreationDate.ToString()); rdata.writer.WriteAttributeString("creationdate", String.Empty, i.CreationDate.ToString());
rdata.writer.WriteAttributeString("type",String.Empty,i.InvType.ToString()); rdata.writer.WriteAttributeString("type", String.Empty, i.InvType.ToString());
rdata.writer.WriteAttributeString("assettype",String.Empty,i.AssetType.ToString()); rdata.writer.WriteAttributeString("assettype", String.Empty, i.AssetType.ToString());
rdata.writer.WriteAttributeString("groupowned",String.Empty,i.GroupOwned.ToString()); rdata.writer.WriteAttributeString("groupowned", String.Empty, i.GroupOwned.ToString());
rdata.writer.WriteAttributeString("groupid",String.Empty,i.GroupID.ToString()); rdata.writer.WriteAttributeString("groupid", String.Empty, i.GroupID.ToString());
rdata.writer.WriteAttributeString("saletype",String.Empty,i.SaleType.ToString()); rdata.writer.WriteAttributeString("saletype", String.Empty, i.SaleType.ToString());
rdata.writer.WriteAttributeString("saleprice",String.Empty,i.SalePrice.ToString()); rdata.writer.WriteAttributeString("saleprice", String.Empty, i.SalePrice.ToString());
rdata.writer.WriteAttributeString("flags",String.Empty,i.Flags.ToString("X")); rdata.writer.WriteAttributeString("flags", String.Empty, i.Flags.ToString());
rdata.writer.WriteStartElement(String.Empty,"Permissions",String.Empty); rdata.writer.WriteStartElement(String.Empty, "Permissions", String.Empty);
rdata.writer.WriteAttributeString("current",String.Empty,i.CurrentPermissions.ToString("X")); rdata.writer.WriteAttributeString("current", String.Empty, i.CurrentPermissions.ToString("X"));
rdata.writer.WriteAttributeString("next",String.Empty,i.NextPermissions.ToString("X")); rdata.writer.WriteAttributeString("next", String.Empty, i.NextPermissions.ToString("X"));
rdata.writer.WriteAttributeString("everyone",String.Empty,i.EveryOnePermissions.ToString("X")); rdata.writer.WriteAttributeString("everyone", String.Empty, i.EveryOnePermissions.ToString("X"));
rdata.writer.WriteAttributeString("base",String.Empty,i.BasePermissions.ToString("X")); rdata.writer.WriteAttributeString("base", String.Empty, i.BasePermissions.ToString("X"));
rdata.writer.WriteEndElement(); rdata.writer.WriteEndElement();
rdata.writer.WriteElementString("Asset",i.AssetID.ToString()); rdata.writer.WriteElementString("Asset", i.AssetID.ToString());
rdata.writer.WriteEndElement(); rdata.writer.WriteEndElement();
} }

View File

@ -63,9 +63,9 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
if (!m_scenes.Contains(scene)) if (!m_scenes.Contains(scene))
{ {
m_scenes.Add(scene); m_scenes.Add(scene);
scene.EventManager.OnNewClient += NewClient; scene.EventManager.OnNewClient += OnNewClient;
scene.EventManager.OnChatFromWorld += SimChat; scene.EventManager.OnChatFromWorld += OnSimChat;
scene.EventManager.OnChatBroadcast += SimBroadcast; scene.EventManager.OnChatBroadcast += OnSimBroadcast;
} }
// wrap this in a try block so that defaults will work if // wrap this in a try block so that defaults will work if
@ -105,7 +105,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
#endregion #endregion
#region ISimChat Members #region ISimChat Members
public void SimBroadcast(Object sender, OSChatMessage c) public void OnSimBroadcast(Object sender, OSChatMessage c)
{ {
// We only want to relay stuff on channel 0 and on the debug channel // We only want to relay stuff on channel 0 and on the debug channel
if (c.Channel != 0 && c.Channel != DEBUG_CHANNEL) return; if (c.Channel != 0 && c.Channel != DEBUG_CHANNEL) return;
@ -116,34 +116,44 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
if (c.Message.Length > 1100) if (c.Message.Length > 1100)
c.Message = c.Message.Substring(0, 1000); c.Message = c.Message.Substring(0, 1000);
// chat works by redistributing every incoming chat // broadcast chat works by redistributing every incoming chat
// message to each avatar in the scene // message to each avatar in the scene.
Vector3 pos = new Vector3(128, 128, 30); Vector3 pos = new Vector3(128, 128, 30);
((Scene)c.Scene).ForEachScenePresence(delegate(ScenePresence presence) ((Scene)c.Scene).ForEachScenePresence(
delegate(ScenePresence presence)
{ {
// ignore chat from child agents
if (presence.IsChildAgent) return; if (presence.IsChildAgent) return;
IClientAPI client = presence.ControllingClient; IClientAPI client = presence.ControllingClient;
// don't forward SayOwner chat from objects to
// non-owner agents
if ((c.Type == ChatTypeEnum.Owner) && if ((c.Type == ChatTypeEnum.Owner) &&
(null != c.SenderObject) && (null != c.SenderObject) &&
(((SceneObjectPart)c.SenderObject).OwnerID != client.AgentId)) (((SceneObjectPart)c.SenderObject).OwnerID != client.AgentId))
return; return;
if (null == c.SenderObject) if (null == c.SenderObject)
{
// chat from agent (avatar)
client.SendChatMessage(c.Message, (byte)c.Type, client.SendChatMessage(c.Message, (byte)c.Type,
pos, c.From, UUID.Zero, pos, c.From, UUID.Zero,
(byte)ChatSourceType.Agent, (byte)ChatSourceType.Agent,
(byte)ChatAudibleLevel.Fully); (byte)ChatAudibleLevel.Fully);
}
else else
{
// chat from object
client.SendChatMessage(c.Message, (byte)c.Type, client.SendChatMessage(c.Message, (byte)c.Type,
pos, c.From, UUID.Zero, pos, c.From, UUID.Zero,
(byte)ChatSourceType.Object, (byte)ChatSourceType.Object,
(byte)ChatAudibleLevel.Fully); (byte)ChatAudibleLevel.Fully);
}
}); });
} }
public void SimChat(Object sender, OSChatMessage e) public void OnSimChat(Object sender, OSChatMessage e)
{ {
// early return if not on public or debug channel // early return if not on public or debug channel
if (e.Channel != 0 && e.Channel != DEBUG_CHANNEL) return; if (e.Channel != 0 && e.Channel != DEBUG_CHANNEL) return;
@ -188,7 +198,8 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
// message to each avatar in the scene // message to each avatar in the scene
foreach (Scene s in m_scenes) foreach (Scene s in m_scenes)
{ {
s.ForEachScenePresence(delegate(ScenePresence presence) s.ForEachScenePresence(
delegate(ScenePresence presence)
{ {
if (e.Channel == DEBUG_CHANNEL) if (e.Channel == DEBUG_CHANNEL)
{ {
@ -208,11 +219,11 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
#endregion #endregion
public void NewClient(IClientAPI client) public void OnNewClient(IClientAPI client)
{ {
try try
{ {
client.OnChatFromViewer += SimChat; client.OnChatFromViewer += OnSimChat;
} }
catch (Exception ex) catch (Exception ex)
{ {

View File

@ -92,8 +92,8 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
if (!m_scenes.Contains(scene)) if (!m_scenes.Contains(scene))
{ {
m_scenes.Add(scene); m_scenes.Add(scene);
scene.EventManager.OnNewClient += NewClient; scene.EventManager.OnNewClient += OnNewClient;
scene.EventManager.OnChatFromWorld += SimChat; scene.EventManager.OnChatFromWorld += OnSimChat;
scene.EventManager.OnMakeRootAgent += OnMakeRootAgent; scene.EventManager.OnMakeRootAgent += OnMakeRootAgent;
scene.EventManager.OnMakeChildAgent += OnMakeChildAgent; scene.EventManager.OnMakeChildAgent += OnMakeChildAgent;
} }
@ -171,7 +171,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
#region ISimChat Members #region ISimChat Members
public void SimChat(Object sender, OSChatMessage e) public void OnSimChat(Object sender, OSChatMessage e)
{ {
// We only want to relay stuff on channel 0 // We only want to relay stuff on channel 0
if (e.Channel != 0) return; if (e.Channel != 0) return;
@ -233,15 +233,15 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
#endregion #endregion
public void NewClient(IClientAPI client) public void OnNewClient(IClientAPI client)
{ {
try try
{ {
string clientName = String.Format("{0} {1}", client.FirstName, client.LastName); string clientName = String.Format("{0} {1}", client.FirstName, client.LastName);
client.OnChatFromViewer += SimChat; client.OnChatFromViewer += OnSimChat;
client.OnLogout += ClientLoggedOut; client.OnLogout += OnClientLoggedOut;
client.OnConnectionClosed += ClientLoggedOut; client.OnConnectionClosed += OnClientLoggedOut;
if (clientName != m_last_new_user) if (clientName != m_last_new_user)
{ {
@ -295,7 +295,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
} }
public void ClientLoggedOut(IClientAPI client) public void OnClientLoggedOut(IClientAPI client)
{ {
lock (m_syncLogout) lock (m_syncLogout)
{ {
@ -614,10 +614,11 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
} }
} }
static private Vector3 pos = new Vector3(128, 128, 20);
public void ListenerRun() public void ListenerRun()
{ {
string inputLine; string inputLine;
Vector3 pos = new Vector3(128, 128, 20);
while (m_enabled) while (m_enabled)
{ {
try try

View File

@ -415,6 +415,7 @@ namespace OpenSim.Region.Environment.Scenes
m_controllingClient = client; m_controllingClient = client;
m_firstname = m_controllingClient.FirstName; m_firstname = m_controllingClient.FirstName;
m_lastname = m_controllingClient.LastName; m_lastname = m_controllingClient.LastName;
m_name = String.Format("{0} {1}", m_firstname, m_lastname);
m_scene = world; m_scene = world;
m_uuid = client.AgentId; m_uuid = client.AgentId;