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