diff options
author | Jeff Ames | 2008-07-23 13:24:25 +0000 |
---|---|---|
committer | Jeff Ames | 2008-07-23 13:24:25 +0000 |
commit | 80d8e2889e62d8900837d37a800a4eeaae5ffc5a (patch) | |
tree | 47bdf0f48ae8ace3bb7cd10ab91d91b52b96f80e /OpenSim/Region/Environment/Modules/Scripting/EMailModules | |
parent | get rid of some LLQuaternion == null checks. Because LLQuaternion is (diff) | |
download | opensim-SC_OLD-80d8e2889e62d8900837d37a800a4eeaae5ffc5a.zip opensim-SC_OLD-80d8e2889e62d8900837d37a800a4eeaae5ffc5a.tar.gz opensim-SC_OLD-80d8e2889e62d8900837d37a800a4eeaae5ffc5a.tar.bz2 opensim-SC_OLD-80d8e2889e62d8900837d37a800a4eeaae5ffc5a.tar.xz |
Update svn properties. Formatting cleanup. Remove a compiler warning.
Diffstat (limited to 'OpenSim/Region/Environment/Modules/Scripting/EMailModules')
-rw-r--r-- | OpenSim/Region/Environment/Modules/Scripting/EMailModules/EmailModule.cs | 266 |
1 files changed, 133 insertions, 133 deletions
diff --git a/OpenSim/Region/Environment/Modules/Scripting/EMailModules/EmailModule.cs b/OpenSim/Region/Environment/Modules/Scripting/EMailModules/EmailModule.cs index c65f958..1162c25 100644 --- a/OpenSim/Region/Environment/Modules/Scripting/EMailModules/EmailModule.cs +++ b/OpenSim/Region/Environment/Modules/Scripting/EMailModules/EmailModule.cs | |||
@@ -78,33 +78,33 @@ namespace OpenSim.Region.Environment.Modules.Scripting.EmailModules | |||
78 | 78 | ||
79 | //Load SMTP SERVER config | 79 | //Load SMTP SERVER config |
80 | try | 80 | try |
81 | { | 81 | { |
82 | if ((SMTPConfig = m_Config.Configs["SMTP"]) == null) | 82 | if ((SMTPConfig = m_Config.Configs["SMTP"]) == null) |
83 | { | 83 | { |
84 | m_log.InfoFormat("[SMTP] SMTP server not configured"); | 84 | m_log.InfoFormat("[SMTP] SMTP server not configured"); |
85 | m_Enabled = false; | 85 | m_Enabled = false; |
86 | return; | 86 | return; |
87 | } | 87 | } |
88 | 88 | ||
89 | if (!SMTPConfig.GetBoolean("enabled", false)) | 89 | if (!SMTPConfig.GetBoolean("enabled", false)) |
90 | { | 90 | { |
91 | m_log.InfoFormat("[SMTP] module disabled in configuration"); | 91 | m_log.InfoFormat("[SMTP] module disabled in configuration"); |
92 | m_Enabled = false; | 92 | m_Enabled = false; |
93 | return; | 93 | return; |
94 | } | 94 | } |
95 | 95 | ||
96 | m_HostName = SMTPConfig.GetString("host_domain_header_from", m_HostName); | 96 | m_HostName = SMTPConfig.GetString("host_domain_header_from", m_HostName); |
97 | SMTP_SERVER_HOSTNAME = SMTPConfig.GetString("SMTP_SERVER_HOSTNAME",SMTP_SERVER_HOSTNAME); | 97 | SMTP_SERVER_HOSTNAME = SMTPConfig.GetString("SMTP_SERVER_HOSTNAME",SMTP_SERVER_HOSTNAME); |
98 | SMTP_SERVER_PORT = SMTPConfig.GetInt("SMTP_SERVER_PORT", SMTP_SERVER_PORT); | 98 | SMTP_SERVER_PORT = SMTPConfig.GetInt("SMTP_SERVER_PORT", SMTP_SERVER_PORT); |
99 | SMTP_SERVER_LOGIN = SMTPConfig.GetString("SMTP_SERVER_LOGIN", SMTP_SERVER_LOGIN); | 99 | SMTP_SERVER_LOGIN = SMTPConfig.GetString("SMTP_SERVER_LOGIN", SMTP_SERVER_LOGIN); |
100 | SMTP_SERVER_PASSWORD = SMTPConfig.GetString("SMTP_SERVER_PASSWORD", SMTP_SERVER_PASSWORD); | 100 | SMTP_SERVER_PASSWORD = SMTPConfig.GetString("SMTP_SERVER_PASSWORD", SMTP_SERVER_PASSWORD); |
101 | } | 101 | } |
102 | catch (Exception e) | 102 | catch (Exception e) |
103 | { | 103 | { |
104 | m_log.Error("[EMAIL] DefaultEmailModule not configured: "+ e.Message); | 104 | m_log.Error("[EMAIL] DefaultEmailModule not configured: "+ e.Message); |
105 | m_Enabled = false; | 105 | m_Enabled = false; |
106 | return; | 106 | return; |
107 | } | 107 | } |
108 | 108 | ||
109 | // It's a go! | 109 | // It's a go! |
110 | if (m_Enabled) | 110 | if (m_Enabled) |
@@ -124,7 +124,7 @@ namespace OpenSim.Region.Environment.Modules.Scripting.EmailModules | |||
124 | m_Scenes.Add(scene.RegionInfo.RegionHandle, scene); | 124 | m_Scenes.Add(scene.RegionInfo.RegionHandle, scene); |
125 | } | 125 | } |
126 | } | 126 | } |
127 | 127 | ||
128 | m_log.Info("[EMAIL] Activated DefaultEmailModule"); | 128 | m_log.Info("[EMAIL] Activated DefaultEmailModule"); |
129 | } | 129 | } |
130 | } | 130 | } |
@@ -152,14 +152,14 @@ namespace OpenSim.Region.Environment.Modules.Scripting.EmailModules | |||
152 | /// </summary> | 152 | /// </summary> |
153 | /// <param name="seconds"></param> | 153 | /// <param name="seconds"></param> |
154 | private void DelayInSeconds(int seconds) | 154 | private void DelayInSeconds(int seconds) |
155 | { | 155 | { |
156 | TimeSpan DiffDelay = new TimeSpan(0, 0, seconds); | 156 | TimeSpan DiffDelay = new TimeSpan(0, 0, seconds); |
157 | DateTime EndDelay = DateTime.Now.Add(DiffDelay); | 157 | DateTime EndDelay = DateTime.Now.Add(DiffDelay); |
158 | while (DateTime.Now < EndDelay) | 158 | while (DateTime.Now < EndDelay) |
159 | { | 159 | { |
160 | ;//Do nothing!! | 160 | ;//Do nothing!! |
161 | } | 161 | } |
162 | } | 162 | } |
163 | 163 | ||
164 | private SceneObjectPart findPrim(LLUUID objectID, out string ObjectRegionName) | 164 | private SceneObjectPart findPrim(LLUUID objectID, out string ObjectRegionName) |
165 | { | 165 | { |
@@ -171,7 +171,7 @@ namespace OpenSim.Region.Environment.Modules.Scripting.EmailModules | |||
171 | if (part != null) | 171 | if (part != null) |
172 | { | 172 | { |
173 | ObjectRegionName = s.RegionInfo.RegionName; | 173 | ObjectRegionName = s.RegionInfo.RegionName; |
174 | return part; | 174 | return part; |
175 | } | 175 | } |
176 | } | 176 | } |
177 | } | 177 | } |
@@ -181,108 +181,108 @@ namespace OpenSim.Region.Environment.Modules.Scripting.EmailModules | |||
181 | 181 | ||
182 | private void resolveNamePositionRegionName(LLUUID objectID, out string ObjectName, out string ObjectAbsolutePosition, out string ObjectRegionName) | 182 | private void resolveNamePositionRegionName(LLUUID objectID, out string ObjectName, out string ObjectAbsolutePosition, out string ObjectRegionName) |
183 | { | 183 | { |
184 | string m_ObjectRegionName; | 184 | string m_ObjectRegionName; |
185 | SceneObjectPart part = findPrim(objectID, out m_ObjectRegionName); | 185 | SceneObjectPart part = findPrim(objectID, out m_ObjectRegionName); |
186 | if (part != null) | 186 | if (part != null) |
187 | { | 187 | { |
188 | ObjectAbsolutePosition = part.AbsolutePosition.ToString(); | 188 | ObjectAbsolutePosition = part.AbsolutePosition.ToString(); |
189 | ObjectName = part.Name; | 189 | ObjectName = part.Name; |
190 | ObjectRegionName = m_ObjectRegionName; | 190 | ObjectRegionName = m_ObjectRegionName; |
191 | return; | 191 | return; |
192 | } | 192 | } |
193 | ObjectAbsolutePosition = part.AbsolutePosition.ToString(); | 193 | ObjectAbsolutePosition = part.AbsolutePosition.ToString(); |
194 | ObjectName = part.Name; | 194 | ObjectName = part.Name; |
195 | ObjectRegionName = m_ObjectRegionName; | 195 | ObjectRegionName = m_ObjectRegionName; |
196 | return; | 196 | return; |
197 | } | 197 | } |
198 | 198 | ||
199 | /// <summary> | 199 | /// <summary> |
200 | /// SendMail function utilized by llEMail | 200 | /// SendMail function utilized by llEMail |
201 | /// </summary> | 201 | /// </summary> |
202 | /// <param name="objectID"></param> | 202 | /// <param name="objectID"></param> |
203 | /// <param name="address"></param> | 203 | /// <param name="address"></param> |
204 | /// <param name="subject"></param> | 204 | /// <param name="subject"></param> |
205 | /// <param name="body"></param> | 205 | /// <param name="body"></param> |
206 | public void SendEmail(LLUUID objectID, string address, string subject, string body) | 206 | public void SendEmail(LLUUID objectID, string address, string subject, string body) |
207 | { | 207 | { |
208 | //Check if address is empty | 208 | //Check if address is empty |
209 | if (address == string.Empty) | 209 | if (address == string.Empty) |
210 | return; | 210 | return; |
211 | 211 | ||
212 | //FIXED:Check the email is correct form in REGEX | 212 | //FIXED:Check the email is correct form in REGEX |
213 | string EMailpatternStrict = @"^(([^<>()[\]\\.,;:\s@\""]+" | 213 | string EMailpatternStrict = @"^(([^<>()[\]\\.,;:\s@\""]+" |
214 | + @"(\.[^<>()[\]\\.,;:\s@\""]+)*)|(\"".+\""))@" | 214 | + @"(\.[^<>()[\]\\.,;:\s@\""]+)*)|(\"".+\""))@" |
215 | + @"((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}" | 215 | + @"((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}" |
216 | + @"\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+" | 216 | + @"\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+" |
217 | + @"[a-zA-Z]{2,}))$"; | 217 | + @"[a-zA-Z]{2,}))$"; |
218 | Regex EMailreStrict = new Regex(EMailpatternStrict); | 218 | Regex EMailreStrict = new Regex(EMailpatternStrict); |
219 | bool isEMailStrictMatch = EMailreStrict.IsMatch(address); | 219 | bool isEMailStrictMatch = EMailreStrict.IsMatch(address); |
220 | if (!isEMailStrictMatch) | 220 | if (!isEMailStrictMatch) |
221 | { | 221 | { |
222 | m_log.Error("[EMAIL] REGEX Problem in EMail Address: "+address); | 222 | m_log.Error("[EMAIL] REGEX Problem in EMail Address: "+address); |
223 | return; | 223 | return; |
224 | } | 224 | } |
225 | //FIXME:Check if subject + body = 4096 Byte | 225 | //FIXME:Check if subject + body = 4096 Byte |
226 | if ((subject.Length + body.Length) > 1024) | 226 | if ((subject.Length + body.Length) > 1024) |
227 | { | 227 | { |
228 | m_log.Error("[EMAIL] subject + body > 1024 Byte"); | 228 | m_log.Error("[EMAIL] subject + body > 1024 Byte"); |
229 | return; | 229 | return; |
230 | } | 230 | } |
231 | 231 | ||
232 | try | 232 | try |
233 | { | 233 | { |
234 | string LastObjectName = string.Empty; | 234 | string LastObjectName = string.Empty; |
235 | string LastObjectPosition = string.Empty; | 235 | string LastObjectPosition = string.Empty; |
236 | string LastObjectRegionName = string.Empty; | 236 | string LastObjectRegionName = string.Empty; |
237 | //DONE: Message as Second Life style | 237 | //DONE: Message as Second Life style |
238 | //20 second delay - AntiSpam System - for now only 10 seconds | 238 | //20 second delay - AntiSpam System - for now only 10 seconds |
239 | DelayInSeconds(10); | 239 | DelayInSeconds(10); |
240 | //Creation EmailMessage | 240 | //Creation EmailMessage |
241 | EmailMessage emailMessage = new EmailMessage(); | 241 | EmailMessage emailMessage = new EmailMessage(); |
242 | //From | 242 | //From |
243 | emailMessage.FromAddress = new EmailAddress(objectID.UUID.ToString()+"@"+m_HostName); | 243 | emailMessage.FromAddress = new EmailAddress(objectID.UUID.ToString()+"@"+m_HostName); |
244 | //To - Only One | 244 | //To - Only One |
245 | emailMessage.AddToAddress(new EmailAddress(address)); | 245 | emailMessage.AddToAddress(new EmailAddress(address)); |
246 | //Subject | 246 | //Subject |
247 | emailMessage.Subject = subject; | 247 | emailMessage.Subject = subject; |
248 | //TEXT Body | 248 | //TEXT Body |
249 | resolveNamePositionRegionName(objectID, out LastObjectName, out LastObjectPosition, out LastObjectRegionName); | 249 | resolveNamePositionRegionName(objectID, out LastObjectName, out LastObjectPosition, out LastObjectRegionName); |
250 | emailMessage.TextPart = new TextAttachment("Object-Name: " + LastObjectName + | 250 | emailMessage.TextPart = new TextAttachment("Object-Name: " + LastObjectName + |
251 | "\r\nRegion: " + LastObjectRegionName + "\r\nLocal-Position: " + | 251 | "\r\nRegion: " + LastObjectRegionName + "\r\nLocal-Position: " + |
252 | LastObjectPosition+"\r\n\r\n\r\n" + body); | 252 | LastObjectPosition+"\r\n\r\n\r\n" + body); |
253 | //HTML Body | 253 | //HTML Body |
254 | emailMessage.HtmlPart = new HtmlAttachment("<html><body><p>" + | 254 | emailMessage.HtmlPart = new HtmlAttachment("<html><body><p>" + |
255 | "<BR>Object-Name: " + LastObjectName + | 255 | "<BR>Object-Name: " + LastObjectName + |
256 | "<BR>Region: " + LastObjectRegionName + | 256 | "<BR>Region: " + LastObjectRegionName + |
257 | "<BR>Local-Position: " + LastObjectPosition + "<BR><BR><BR>" | 257 | "<BR>Local-Position: " + LastObjectPosition + "<BR><BR><BR>" |
258 | +body+"\r\n</p></body><html>"); | 258 | +body+"\r\n</p></body><html>"); |
259 | 259 | ||
260 | //Set SMTP SERVER config | 260 | //Set SMTP SERVER config |
261 | SmtpServer smtpServer=new SmtpServer(SMTP_SERVER_HOSTNAME,SMTP_SERVER_PORT); | 261 | SmtpServer smtpServer=new SmtpServer(SMTP_SERVER_HOSTNAME,SMTP_SERVER_PORT); |
262 | //Authentication | 262 | //Authentication |
263 | smtpServer.SmtpAuthToken=new SmtpAuthToken(SMTP_SERVER_LOGIN, SMTP_SERVER_PASSWORD); | 263 | smtpServer.SmtpAuthToken=new SmtpAuthToken(SMTP_SERVER_LOGIN, SMTP_SERVER_PASSWORD); |
264 | //Send Email Message | 264 | //Send Email Message |
265 | emailMessage.Send(smtpServer); | 265 | emailMessage.Send(smtpServer); |
266 | //Log | 266 | //Log |
267 | m_log.Info("[EMAIL] EMail sent to: " + address + " from object: " + objectID.UUID.ToString()); | 267 | m_log.Info("[EMAIL] EMail sent to: " + address + " from object: " + objectID.UUID.ToString()); |
268 | } | 268 | } |
269 | catch (Exception e) | 269 | catch (Exception e) |
270 | { | 270 | { |
271 | m_log.Error("[EMAIL] DefaultEmailModule Exception: "+e.Message); | 271 | m_log.Error("[EMAIL] DefaultEmailModule Exception: "+e.Message); |
272 | return; | 272 | return; |
273 | } | 273 | } |
274 | } | 274 | } |
275 | 275 | ||
276 | /// <summary> | 276 | /// <summary> |
277 | /// | 277 | /// |
278 | /// </summary> | 278 | /// </summary> |
279 | /// <param name="objectID"></param> | 279 | /// <param name="objectID"></param> |
280 | /// <param name="sender"></param> | 280 | /// <param name="sender"></param> |
281 | /// <param name="subject"></param> | 281 | /// <param name="subject"></param> |
282 | /// <returns></returns> | 282 | /// <returns></returns> |
283 | public Email GetNextEmail(LLUUID objectID, string sender, string subject) | 283 | public Email GetNextEmail(LLUUID objectID, string sender, string subject) |
284 | { | 284 | { |
285 | return null; | 285 | return null; |
286 | } | 286 | } |
287 | } | 287 | } |
288 | } | 288 | } |