From 388c053dcb8de3d9b89c99989af1990296cf2001 Mon Sep 17 00:00:00 2001
From: Melanie Thielker
Date: Sat, 1 Nov 2008 18:18:19 +0000
Subject: Make the IM and friends modules optional. Clean up some code that
dealt with the old Grid Instant Message over OGS1. Refactor the EventManager
to be independent of the rigid module structure design imposed by the current
implementation. Message routing is now done in the destination module rather
than in the event manager. This way, more or less granular solutions are
possible without core changes.
---
.../Modules/Avatar/Friends/FriendsModule.cs | 7 ++++--
.../Modules/Avatar/Groups/GroupsModule.cs | 7 ++++--
.../Avatar/InstantMessage/InstantMessageModule.cs | 19 ++++++++++++---
.../Modules/InterGrid/OpenGridProtocolModule.cs | 6 -----
OpenSim/Region/Environment/Scenes/EventManager.cs | 28 +++++-----------------
5 files changed, 32 insertions(+), 35 deletions(-)
(limited to 'OpenSim/Region/Environment')
diff --git a/OpenSim/Region/Environment/Modules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/Environment/Modules/Avatar/Friends/FriendsModule.cs
index c51bcc1..a380700 100644
--- a/OpenSim/Region/Environment/Modules/Avatar/Friends/FriendsModule.cs
+++ b/OpenSim/Region/Environment/Modules/Avatar/Friends/FriendsModule.cs
@@ -67,7 +67,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
m_scene.Add(scene);
}
scene.EventManager.OnNewClient += OnNewClient;
- scene.EventManager.OnGridInstantMessageToFriendsModule += OnGridInstantMessage;
+ scene.EventManager.OnGridInstantMessage += OnGridInstantMessage;
scene.EventManager.OnAvatarEnteringNewParcel += AvatarEnteringParcel;
scene.EventManager.OnMakeChildAgent += MakeChildAgent;
scene.EventManager.OnClientClosed += ClientLoggedOut;
@@ -620,8 +620,11 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
// TODO: Inform the client that the ExFriend is offline
}
- private void OnGridInstantMessage(GridInstantMessage msg)
+ private void OnGridInstantMessage(GridInstantMessage msg, InstantMessageReceiver whichModule)
{
+ if ((whichModule & InstantMessageReceiver.FriendsModule) == 0)
+ return;
+
// Trigger the above event handler
OnInstantMessage(null, new UUID(msg.fromAgentID), new UUID(msg.fromAgentSession),
new UUID(msg.toAgentID), new UUID(msg.imSessionID), msg.timestamp, msg.fromAgentName,
diff --git a/OpenSim/Region/Environment/Modules/Avatar/Groups/GroupsModule.cs b/OpenSim/Region/Environment/Modules/Avatar/Groups/GroupsModule.cs
index 1824134..d9a5393 100644
--- a/OpenSim/Region/Environment/Modules/Avatar/Groups/GroupsModule.cs
+++ b/OpenSim/Region/Environment/Modules/Avatar/Groups/GroupsModule.cs
@@ -99,7 +99,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Groups
scene.EventManager.OnNewClient += OnNewClient;
scene.EventManager.OnClientClosed += OnClientClosed;
- scene.EventManager.OnGridInstantMessageToGroupsModule +=
+ scene.EventManager.OnGridInstantMessage +=
OnGridInstantMessage;
}
@@ -187,8 +187,11 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Groups
{
}
- private void OnGridInstantMessage(GridInstantMessage msg)
+ private void OnGridInstantMessage(GridInstantMessage msg, InstantMessageReceiver whichModule)
{
+ if ((whichModule & InstantMessageReceiver.GroupsModule) == 0)
+ return;
+
// Trigger the above event handler
OnInstantMessage(null, new UUID(msg.fromAgentID),
new UUID(msg.fromAgentSession),
diff --git a/OpenSim/Region/Environment/Modules/Avatar/InstantMessage/InstantMessageModule.cs b/OpenSim/Region/Environment/Modules/Avatar/InstantMessage/InstantMessageModule.cs
index 2553266..adf1103 100644
--- a/OpenSim/Region/Environment/Modules/Avatar/InstantMessage/InstantMessageModule.cs
+++ b/OpenSim/Region/Environment/Modules/Avatar/InstantMessage/InstantMessageModule.cs
@@ -54,6 +54,14 @@ namespace OpenSim.Region.Environment.Modules.Avatar.InstantMessage
public void Initialise(Scene scene, IConfigSource config)
{
+ if (config.Configs["Messaging"] != null)
+ {
+ if (config.Configs["Messaging"].GetString(
+ "InstantMessageModule", "InstantMessageModule") !=
+ "InstantMessageModule")
+ return;
+ }
+
lock (m_scenes)
{
if (m_scenes.Count == 0)
@@ -67,7 +75,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.InstantMessage
{
m_scenes.Add(scene);
scene.EventManager.OnNewClient += OnNewClient;
- scene.EventManager.OnGridInstantMessageToIMModule += OnGridInstantMessage;
+ scene.EventManager.OnGridInstantMessage += OnGridInstantMessage;
}
}
}
@@ -114,7 +122,9 @@ namespace OpenSim.Region.Environment.Modules.Avatar.InstantMessage
byte[] binaryBucket)
{
bool dialogHandledElsewhere
- = ((dialog == 38) || (dialog == 39) || (dialog == 40)
+ = ( dialog == (byte) InstantMessageDialog.FriendshipOffered
+ || dialog == (byte) InstantMessageDialog.FriendshipAccepted
+ || dialog == (byte) InstantMessageDialog.FriendshipDeclined
|| dialog == (byte) InstantMessageDialog.InventoryOffered
|| dialog == (byte) InstantMessageDialog.InventoryAccepted
|| dialog == (byte) InstantMessageDialog.InventoryDeclined
@@ -197,8 +207,11 @@ namespace OpenSim.Region.Environment.Modules.Avatar.InstantMessage
///
///
///
- private void OnGridInstantMessage(GridInstantMessage msg)
+ private void OnGridInstantMessage(GridInstantMessage msg, InstantMessageReceiver which)
{
+ if ((which & InstantMessageReceiver.IMModule) == 0)
+ return;
+
// Trigger the above event handler
OnInstantMessage(null, new UUID(msg.fromAgentID), new UUID(msg.fromAgentSession),
new UUID(msg.toAgentID), new UUID(msg.imSessionID), msg.timestamp, msg.fromAgentName,
diff --git a/OpenSim/Region/Environment/Modules/InterGrid/OpenGridProtocolModule.cs b/OpenSim/Region/Environment/Modules/InterGrid/OpenGridProtocolModule.cs
index 85e60d7..ba40571 100644
--- a/OpenSim/Region/Environment/Modules/InterGrid/OpenGridProtocolModule.cs
+++ b/OpenSim/Region/Environment/Modules/InterGrid/OpenGridProtocolModule.cs
@@ -195,12 +195,6 @@ namespace OpenSim.Region.Environment.Modules.InterGrid
}
}
}
- // Of interest to this module potentially
- //scene.EventManager.OnNewClient += OnNewClient;
- //scene.EventManager.OnGridInstantMessageToFriendsModule += OnGridInstantMessage;
- // scene.EventManager.OnAvatarEnteringNewParcel += AvatarEnteringParcel;
- //scene.EventManager.OnMakeChildAgent += MakeChildAgent;
- //scene.EventManager.OnClientClosed += ClientLoggedOut;
}
public void PostInitialise()
diff --git a/OpenSim/Region/Environment/Scenes/EventManager.cs b/OpenSim/Region/Environment/Scenes/EventManager.cs
index c629faf..99aac93 100644
--- a/OpenSim/Region/Environment/Scenes/EventManager.cs
+++ b/OpenSim/Region/Environment/Scenes/EventManager.cs
@@ -135,13 +135,9 @@ namespace OpenSim.Region.Environment.Scenes
public event SignificantClientMovement OnSignificantClientMovement;
- public delegate void NewGridInstantMessage(GridInstantMessage message);
+ public delegate void NewGridInstantMessage(GridInstantMessage message, InstantMessageReceiver whichModule);
- public event NewGridInstantMessage OnGridInstantMessageToIMModule;
-
- public event NewGridInstantMessage OnGridInstantMessageToFriendsModule;
-
- public event NewGridInstantMessage OnGridInstantMessageToGroupsModule;
+ public event NewGridInstantMessage OnGridInstantMessage;
public delegate void ClientClosed(UUID clientID);
@@ -346,8 +342,7 @@ namespace OpenSim.Region.Environment.Scenes
private LandObjectAdded handlerLandObjectAdded = null; //OnLandObjectAdded;
private LandObjectRemoved handlerLandObjectRemoved = null; //OnLandObjectRemoved;
private AvatarEnteringNewParcel handlerAvatarEnteringNewParcel = null; //OnAvatarEnteringNewParcel;
- private NewGridInstantMessage handlerGridInstantMessageToIM = null; //OnGridInstantMessageToIMModule;
- private NewGridInstantMessage handlerGridInstantMessageToFriends = null; //OnGridInstantMessageToFriendsModule;
+ private NewGridInstantMessage handlerGridInstantMessage = null; //OnGridInstantMessage;
private ClientClosed handlerClientClosed = null; //OnClientClosed;
private OnMakeChildAgentDelegate handlerMakeChildAgent = null; //OnMakeChildAgent;
private OnMakeRootAgentDelegate handlerMakeRootAgent = null; //OnMakeRootAgent;
@@ -635,21 +630,10 @@ namespace OpenSim.Region.Environment.Scenes
///A bit vector containing the modules to send the message to
public void TriggerGridInstantMessage(GridInstantMessage message, InstantMessageReceiver whichModule)
{
- if ((whichModule & InstantMessageReceiver.IMModule) != 0)
- {
- handlerGridInstantMessageToIM = OnGridInstantMessageToIMModule;
- if (handlerGridInstantMessageToIM != null)
- {
- handlerGridInstantMessageToIM(message);
- }
- }
- if ((whichModule & InstantMessageReceiver.FriendsModule) != 0)
+ handlerGridInstantMessage = OnGridInstantMessage;
+ if (handlerGridInstantMessage != null)
{
- handlerGridInstantMessageToFriends = OnGridInstantMessageToFriendsModule;
- if (handlerGridInstantMessageToFriends != null)
- {
- handlerGridInstantMessageToFriends(message);
- }
+ handlerGridInstantMessage(message, whichModule);
}
}
--
cgit v1.1