- 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

@ -1285,33 +1285,33 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
private void formatItem(InventoryRequestData rdata, InventoryItemBase i, string indent) private void formatItem(InventoryRequestData rdata, InventoryItemBase i, string indent)
{ {
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)
if (presence.IsChildAgent) return; {
// ignore chat from child agents
IClientAPI client = presence.ControllingClient; if (presence.IsChildAgent) return;
if ((c.Type == ChatTypeEnum.Owner) && IClientAPI client = presence.ControllingClient;
(null != c.SenderObject) &&
(((SceneObjectPart)c.SenderObject).OwnerID != client.AgentId)) // don't forward SayOwner chat from objects to
return; // non-owner agents
if ((c.Type == ChatTypeEnum.Owner) &&
if (null == c.SenderObject) (null != c.SenderObject) &&
client.SendChatMessage(c.Message, (byte)c.Type, (((SceneObjectPart)c.SenderObject).OwnerID != client.AgentId))
pos, c.From, UUID.Zero, return;
(byte)ChatSourceType.Agent,
(byte)ChatAudibleLevel.Fully); if (null == c.SenderObject)
else {
client.SendChatMessage(c.Message, (byte)c.Type, // chat from agent (avatar)
pos, c.From, UUID.Zero, client.SendChatMessage(c.Message, (byte)c.Type,
(byte)ChatSourceType.Object, pos, c.From, UUID.Zero,
(byte)ChatAudibleLevel.Fully); (byte)ChatSourceType.Agent,
}); (byte)ChatAudibleLevel.Fully);
}
else
{
// chat from object
client.SendChatMessage(c.Message, (byte)c.Type,
pos, c.From, UUID.Zero,
(byte)ChatSourceType.Object,
(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;
@ -176,7 +186,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
{ {
fromPos = avatar.AbsolutePosition; fromPos = avatar.AbsolutePosition;
regionPos = new Vector3(scene.RegionInfo.RegionLocX * Constants.RegionSize, regionPos = new Vector3(scene.RegionInfo.RegionLocX * Constants.RegionSize,
scene.RegionInfo.RegionLocY * Constants.RegionSize, 0); scene.RegionInfo.RegionLocY * Constants.RegionSize, 0);
fromName = avatar.Firstname + " " + avatar.Lastname; fromName = avatar.Firstname + " " + avatar.Lastname;
fromID = e.Sender.AgentId; fromID = e.Sender.AgentId;
} }
@ -188,31 +198,32 @@ 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)
TrySendChatMessage(presence, fromPos, regionPos, {
fromID, fromName, e.Type, TrySendChatMessage(presence, fromPos, regionPos,
message, ChatSourceType.Object); fromID, fromName, e.Type,
} message, ChatSourceType.Object);
else }
{ else
TrySendChatMessage(presence, fromPos, regionPos, {
fromID, fromName, e.Type, TrySendChatMessage(presence, fromPos, regionPos,
message, ChatSourceType.Agent); fromID, fromName, e.Type,
} message, ChatSourceType.Agent);
}); }
});
} }
} }
#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)
{ {
@ -229,8 +240,8 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
Vector3 fromRegionPos = fromPos + regionPos; Vector3 fromRegionPos = fromPos + regionPos;
Vector3 toRegionPos = presence.AbsolutePosition + Vector3 toRegionPos = presence.AbsolutePosition +
new Vector3(presence.Scene.RegionInfo.RegionLocX * Constants.RegionSize, new Vector3(presence.Scene.RegionInfo.RegionLocX * Constants.RegionSize,
presence.Scene.RegionInfo.RegionLocY * Constants.RegionSize, 0); presence.Scene.RegionInfo.RegionLocY * Constants.RegionSize, 0);
int dis = Math.Abs((int) Util.GetDistanceTo(toRegionPos, fromRegionPos)); int dis = Math.Abs((int) Util.GetDistanceTo(toRegionPos, fromRegionPos));

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;