diff options
author | Diva Canto | 2012-11-11 14:00:58 -0800 |
---|---|---|
committer | Diva Canto | 2012-11-11 14:00:58 -0800 |
commit | 84be90e5f83835800443dde3473545ad73c62a9b (patch) | |
tree | 21e3bcc4b4e4aee5b899037949f620da1c0fa32a | |
parent | document & 80-character width terminal formatting (diff) | |
download | opensim-SC_OLD-84be90e5f83835800443dde3473545ad73c62a9b.zip opensim-SC_OLD-84be90e5f83835800443dde3473545ad73c62a9b.tar.gz opensim-SC_OLD-84be90e5f83835800443dde3473545ad73c62a9b.tar.bz2 opensim-SC_OLD-84be90e5f83835800443dde3473545ad73c62a9b.tar.xz |
One more module converted: EmailModule.
-rw-r--r-- | OpenSim/Region/CoreModules/Scripting/EMailModules/EmailModule.cs | 110 |
1 files changed, 64 insertions, 46 deletions
diff --git a/OpenSim/Region/CoreModules/Scripting/EMailModules/EmailModule.cs b/OpenSim/Region/CoreModules/Scripting/EMailModules/EmailModule.cs index e91e8b9..d943b20 100644 --- a/OpenSim/Region/CoreModules/Scripting/EMailModules/EmailModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/EMailModules/EmailModule.cs | |||
@@ -37,10 +37,12 @@ using OpenMetaverse; | |||
37 | using OpenSim.Framework; | 37 | using OpenSim.Framework; |
38 | using OpenSim.Region.Framework.Interfaces; | 38 | using OpenSim.Region.Framework.Interfaces; |
39 | using OpenSim.Region.Framework.Scenes; | 39 | using OpenSim.Region.Framework.Scenes; |
40 | using Mono.Addins; | ||
40 | 41 | ||
41 | namespace OpenSim.Region.CoreModules.Scripting.EmailModules | 42 | namespace OpenSim.Region.CoreModules.Scripting.EmailModules |
42 | { | 43 | { |
43 | public class EmailModule : IRegionModule, IEmailModule | 44 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "EmailModule")] |
45 | public class EmailModule : ISharedRegionModule, IEmailModule | ||
44 | { | 46 | { |
45 | // | 47 | // |
46 | // Log | 48 | // Log |
@@ -72,31 +74,9 @@ namespace OpenSim.Region.CoreModules.Scripting.EmailModules | |||
72 | 74 | ||
73 | private bool m_Enabled = false; | 75 | private bool m_Enabled = false; |
74 | 76 | ||
75 | public void InsertEmail(UUID to, Email email) | 77 | #region ISharedRegionModule |
76 | { | ||
77 | // It's tempting to create the queue here. Don't; objects which have | ||
78 | // not yet called GetNextEmail should have no queue, and emails to them | ||
79 | // should be silently dropped. | ||
80 | |||
81 | lock (m_MailQueues) | ||
82 | { | ||
83 | if (m_MailQueues.ContainsKey(to)) | ||
84 | { | ||
85 | if (m_MailQueues[to].Count >= m_MaxQueueSize) | ||
86 | { | ||
87 | // fail silently | ||
88 | return; | ||
89 | } | ||
90 | |||
91 | lock (m_MailQueues[to]) | ||
92 | { | ||
93 | m_MailQueues[to].Add(email); | ||
94 | } | ||
95 | } | ||
96 | } | ||
97 | } | ||
98 | 78 | ||
99 | public void Initialise(Scene scene, IConfigSource config) | 79 | public void Initialise(IConfigSource config) |
100 | { | 80 | { |
101 | m_Config = config; | 81 | m_Config = config; |
102 | IConfig SMTPConfig; | 82 | IConfig SMTPConfig; |
@@ -129,36 +109,44 @@ namespace OpenSim.Region.CoreModules.Scripting.EmailModules | |||
129 | SMTP_SERVER_PORT = SMTPConfig.GetInt("SMTP_SERVER_PORT", SMTP_SERVER_PORT); | 109 | SMTP_SERVER_PORT = SMTPConfig.GetInt("SMTP_SERVER_PORT", SMTP_SERVER_PORT); |
130 | SMTP_SERVER_LOGIN = SMTPConfig.GetString("SMTP_SERVER_LOGIN", SMTP_SERVER_LOGIN); | 110 | SMTP_SERVER_LOGIN = SMTPConfig.GetString("SMTP_SERVER_LOGIN", SMTP_SERVER_LOGIN); |
131 | SMTP_SERVER_PASSWORD = SMTPConfig.GetString("SMTP_SERVER_PASSWORD", SMTP_SERVER_PASSWORD); | 111 | SMTP_SERVER_PASSWORD = SMTPConfig.GetString("SMTP_SERVER_PASSWORD", SMTP_SERVER_PASSWORD); |
132 | m_MaxEmailSize = SMTPConfig.GetInt("email_max_size", m_MaxEmailSize); | 112 | m_MaxEmailSize = SMTPConfig.GetInt("email_max_size", m_MaxEmailSize); |
133 | } | 113 | } |
134 | catch (Exception e) | 114 | catch (Exception e) |
135 | { | 115 | { |
136 | m_log.Error("[EMAIL] DefaultEmailModule not configured: "+ e.Message); | 116 | m_log.Error("[EMAIL] DefaultEmailModule not configured: " + e.Message); |
137 | m_Enabled = false; | 117 | m_Enabled = false; |
138 | return; | 118 | return; |
139 | } | 119 | } |
140 | 120 | ||
141 | // It's a go! | 121 | } |
142 | if (m_Enabled) | 122 | |
123 | public void AddRegion(Scene scene) | ||
124 | { | ||
125 | if (!m_Enabled) | ||
126 | return; | ||
127 | |||
128 | // It's a go! | ||
129 | lock (m_Scenes) | ||
143 | { | 130 | { |
144 | lock (m_Scenes) | 131 | // Claim the interface slot |
145 | { | 132 | scene.RegisterModuleInterface<IEmailModule>(this); |
146 | // Claim the interface slot | ||
147 | scene.RegisterModuleInterface<IEmailModule>(this); | ||
148 | 133 | ||
149 | // Add to scene list | 134 | // Add to scene list |
150 | if (m_Scenes.ContainsKey(scene.RegionInfo.RegionHandle)) | 135 | if (m_Scenes.ContainsKey(scene.RegionInfo.RegionHandle)) |
151 | { | 136 | { |
152 | m_Scenes[scene.RegionInfo.RegionHandle] = scene; | 137 | m_Scenes[scene.RegionInfo.RegionHandle] = scene; |
153 | } | 138 | } |
154 | else | 139 | else |
155 | { | 140 | { |
156 | m_Scenes.Add(scene.RegionInfo.RegionHandle, scene); | 141 | m_Scenes.Add(scene.RegionInfo.RegionHandle, scene); |
157 | } | ||
158 | } | 142 | } |
159 | |||
160 | m_log.Info("[EMAIL] Activated DefaultEmailModule"); | ||
161 | } | 143 | } |
144 | |||
145 | m_log.Info("[EMAIL] Activated DefaultEmailModule"); | ||
146 | } | ||
147 | |||
148 | public void RemoveRegion(Scene scene) | ||
149 | { | ||
162 | } | 150 | } |
163 | 151 | ||
164 | public void PostInitialise() | 152 | public void PostInitialise() |
@@ -174,9 +162,39 @@ namespace OpenSim.Region.CoreModules.Scripting.EmailModules | |||
174 | get { return "DefaultEmailModule"; } | 162 | get { return "DefaultEmailModule"; } |
175 | } | 163 | } |
176 | 164 | ||
177 | public bool IsSharedModule | 165 | public Type ReplaceableInterface |
166 | { | ||
167 | get { return null; } | ||
168 | } | ||
169 | |||
170 | public void RegionLoaded(Scene scene) | ||
178 | { | 171 | { |
179 | get { return true; } | 172 | } |
173 | |||
174 | #endregion | ||
175 | |||
176 | public void InsertEmail(UUID to, Email email) | ||
177 | { | ||
178 | // It's tempting to create the queue here. Don't; objects which have | ||
179 | // not yet called GetNextEmail should have no queue, and emails to them | ||
180 | // should be silently dropped. | ||
181 | |||
182 | lock (m_MailQueues) | ||
183 | { | ||
184 | if (m_MailQueues.ContainsKey(to)) | ||
185 | { | ||
186 | if (m_MailQueues[to].Count >= m_MaxQueueSize) | ||
187 | { | ||
188 | // fail silently | ||
189 | return; | ||
190 | } | ||
191 | |||
192 | lock (m_MailQueues[to]) | ||
193 | { | ||
194 | m_MailQueues[to].Add(email); | ||
195 | } | ||
196 | } | ||
197 | } | ||
180 | } | 198 | } |
181 | 199 | ||
182 | private bool IsLocal(UUID objectID) | 200 | private bool IsLocal(UUID objectID) |