diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs | 81 |
1 files changed, 45 insertions, 36 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs index ff38b6f..fdfcd10 100644 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs | |||
@@ -40,82 +40,91 @@ using OpenSim.Region.Framework.Scenes; | |||
40 | 40 | ||
41 | namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | 41 | namespace OpenSim.Region.CoreModules.Avatar.InstantMessage |
42 | { | 42 | { |
43 | public class OfflineMessageModule : IRegionModule | 43 | public class OfflineMessageModule : ISharedRegionModule |
44 | { | 44 | { |
45 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 45 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
46 | 46 | ||
47 | private bool enabled = true; | 47 | private bool enabled = true; |
48 | private List<Scene> m_SceneList = new List<Scene>(); | 48 | private List<Scene> m_SceneList = new List<Scene>(); |
49 | private string m_RestURL = String.Empty; | 49 | private string m_RestURL = String.Empty; |
50 | IMessageTransferModule m_TransferModule = null; | ||
50 | private bool m_ForwardOfflineGroupMessages = true; | 51 | private bool m_ForwardOfflineGroupMessages = true; |
51 | 52 | ||
52 | public void Initialise(Scene scene, IConfigSource config) | 53 | public void Initialise(IConfigSource config) |
53 | { | 54 | { |
54 | if (!enabled) | ||
55 | return; | ||
56 | |||
57 | IConfig cnf = config.Configs["Messaging"]; | 55 | IConfig cnf = config.Configs["Messaging"]; |
58 | if (cnf == null) | 56 | if (cnf == null) |
59 | { | 57 | { |
60 | enabled = false; | 58 | enabled = false; |
61 | return; | 59 | return; |
62 | } | 60 | } |
63 | if (cnf != null && cnf.GetString( | 61 | if (cnf != null && cnf.GetString("OfflineMessageModule", "None") != |
64 | "OfflineMessageModule", "None") != | ||
65 | "OfflineMessageModule") | 62 | "OfflineMessageModule") |
66 | { | 63 | { |
67 | enabled = false; | 64 | enabled = false; |
68 | return; | 65 | return; |
69 | } | 66 | } |
70 | 67 | ||
71 | if (cnf != null) | 68 | m_RestURL = cnf.GetString("OfflineMessageURL", ""); |
72 | m_ForwardOfflineGroupMessages = cnf.GetBoolean("ForwardOfflineGroupMessages", m_ForwardOfflineGroupMessages); | 69 | if (m_RestURL == "") |
70 | { | ||
71 | m_log.Error("[OFFLINE MESSAGING] Module was enabled, but no URL is given, disabling"); | ||
72 | enabled = false; | ||
73 | return; | ||
74 | } | ||
75 | |||
76 | m_ForwardOfflineGroupMessages = cnf.GetBoolean("ForwardOfflineGroupMessages", m_ForwardOfflineGroupMessages); | ||
77 | } | ||
78 | |||
79 | public void AddRegion(Scene scene) | ||
80 | { | ||
81 | if (!enabled) | ||
82 | return; | ||
73 | 83 | ||
74 | lock (m_SceneList) | 84 | lock (m_SceneList) |
75 | { | 85 | { |
76 | if (m_SceneList.Count == 0) | 86 | m_SceneList.Add(scene); |
77 | { | ||
78 | m_RestURL = cnf.GetString("OfflineMessageURL", ""); | ||
79 | if (m_RestURL == "") | ||
80 | { | ||
81 | m_log.Error("[OFFLINE MESSAGING] Module was enabled, but no URL is given, disabling"); | ||
82 | enabled = false; | ||
83 | return; | ||
84 | } | ||
85 | } | ||
86 | if (!m_SceneList.Contains(scene)) | ||
87 | m_SceneList.Add(scene); | ||
88 | 87 | ||
89 | scene.EventManager.OnNewClient += OnNewClient; | 88 | scene.EventManager.OnNewClient += OnNewClient; |
90 | } | 89 | } |
91 | } | 90 | } |
92 | 91 | ||
93 | public void PostInitialise() | 92 | public void RegionLoaded(Scene scene) |
94 | { | 93 | { |
95 | if (!enabled) | 94 | if (!enabled) |
96 | return; | 95 | return; |
97 | 96 | ||
98 | if (m_SceneList.Count == 0) | 97 | if (m_TransferModule == null) |
99 | return; | ||
100 | |||
101 | IMessageTransferModule trans = m_SceneList[0].RequestModuleInterface<IMessageTransferModule>(); | ||
102 | if (trans == null) | ||
103 | { | 98 | { |
104 | enabled = false; | 99 | m_TransferModule = scene.RequestModuleInterface<IMessageTransferModule>(); |
105 | 100 | if (m_TransferModule == null) | |
106 | lock (m_SceneList) | ||
107 | { | 101 | { |
108 | foreach (Scene s in m_SceneList) | 102 | scene.EventManager.OnNewClient -= OnNewClient; |
109 | s.EventManager.OnNewClient -= OnNewClient; | ||
110 | 103 | ||
104 | enabled = false; | ||
111 | m_SceneList.Clear(); | 105 | m_SceneList.Clear(); |
106 | |||
107 | m_log.Error("[OFFLINE MESSAGING] No message transfer module is enabled. Diabling offline messages"); | ||
112 | } | 108 | } |
109 | m_TransferModule.OnUndeliveredMessage += UndeliveredMessage; | ||
110 | } | ||
111 | } | ||
113 | 112 | ||
114 | m_log.Error("[OFFLINE MESSAGING] No message transfer module is enabled. Diabling offline messages"); | 113 | public void RemoveRegion(Scene scene) |
114 | { | ||
115 | if (!enabled) | ||
115 | return; | 116 | return; |
117 | |||
118 | lock (m_SceneList) | ||
119 | { | ||
120 | m_SceneList.Remove(scene); | ||
116 | } | 121 | } |
122 | } | ||
117 | 123 | ||
118 | trans.OnUndeliveredMessage += UndeliveredMessage; | 124 | public void PostInitialise() |
125 | { | ||
126 | if (!enabled) | ||
127 | return; | ||
119 | 128 | ||
120 | m_log.Debug("[OFFLINE MESSAGING] Offline messages enabled"); | 129 | m_log.Debug("[OFFLINE MESSAGING] Offline messages enabled"); |
121 | } | 130 | } |
@@ -125,9 +134,9 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
125 | get { return "OfflineMessageModule"; } | 134 | get { return "OfflineMessageModule"; } |
126 | } | 135 | } |
127 | 136 | ||
128 | public bool IsSharedModule | 137 | public Type ReplaceableInterface |
129 | { | 138 | { |
130 | get { return true; } | 139 | get { return null; } |
131 | } | 140 | } |
132 | 141 | ||
133 | public void Close() | 142 | public void Close() |