diff options
author | Jacek Antonelli | 2008-08-15 23:44:50 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:44:50 -0500 |
commit | 89fe5dab825a62a0e3fd8d248cbc91c65eb2a426 (patch) | |
tree | bcff14b7888d04a2fec799c59369f6095224bd08 /linden/indra/llmessage/llmail.cpp | |
parent | Second Life viewer sources 1.13.3.2 (diff) | |
download | meta-impy-89fe5dab825a62a0e3fd8d248cbc91c65eb2a426.zip meta-impy-89fe5dab825a62a0e3fd8d248cbc91c65eb2a426.tar.gz meta-impy-89fe5dab825a62a0e3fd8d248cbc91c65eb2a426.tar.bz2 meta-impy-89fe5dab825a62a0e3fd8d248cbc91c65eb2a426.tar.xz |
Second Life viewer sources 1.14.0.0
Diffstat (limited to 'linden/indra/llmessage/llmail.cpp')
-rw-r--r-- | linden/indra/llmessage/llmail.cpp | 64 |
1 files changed, 55 insertions, 9 deletions
diff --git a/linden/indra/llmessage/llmail.cpp b/linden/indra/llmessage/llmail.cpp index e84d097..aea3689 100644 --- a/linden/indra/llmessage/llmail.cpp +++ b/linden/indra/llmessage/llmail.cpp | |||
@@ -27,6 +27,8 @@ | |||
27 | 27 | ||
28 | #include "linden_common.h" | 28 | #include "linden_common.h" |
29 | 29 | ||
30 | #include "llmail.h" | ||
31 | |||
30 | // APR on Windows needs full windows headers | 32 | // APR on Windows needs full windows headers |
31 | #ifdef LL_WINDOWS | 33 | #ifdef LL_WINDOWS |
32 | # undef WIN32_LEAN_AND_MEAN | 34 | # undef WIN32_LEAN_AND_MEAN |
@@ -38,14 +40,16 @@ | |||
38 | #include <sstream> | 40 | #include <sstream> |
39 | #include <boost/regex.hpp> | 41 | #include <boost/regex.hpp> |
40 | 42 | ||
41 | #include "llmail.h" | ||
42 | |||
43 | #include "apr-1/apr_pools.h" | 43 | #include "apr-1/apr_pools.h" |
44 | #include "apr-1/apr_network_io.h" | 44 | #include "apr-1/apr_network_io.h" |
45 | 45 | ||
46 | #include "llapr.h" | 46 | #include "llapr.h" |
47 | #include "llbase32.h" // IM-to-email address | ||
48 | #include "llblowfishcipher.h" | ||
47 | #include "llerror.h" | 49 | #include "llerror.h" |
48 | #include "llhost.h" | 50 | #include "llhost.h" |
51 | #include "llstring.h" | ||
52 | #include "lluuid.h" | ||
49 | #include "net.h" | 53 | #include "net.h" |
50 | 54 | ||
51 | // | 55 | // |
@@ -105,11 +109,12 @@ void disconnect_smtp() | |||
105 | 109 | ||
106 | // Returns TRUE on success. | 110 | // Returns TRUE on success. |
107 | // message should NOT be SMTP escaped. | 111 | // message should NOT be SMTP escaped. |
108 | BOOL send_mail(const char* from_name, const char* from_address, | 112 | // static |
113 | BOOL LLMail::send(const char* from_name, const char* from_address, | ||
109 | const char* to_name, const char* to_address, | 114 | const char* to_name, const char* to_address, |
110 | const char* subject, const char* message) | 115 | const char* subject, const char* message) |
111 | { | 116 | { |
112 | std::string header = build_smtp_transaction( | 117 | std::string header = buildSMTPTransaction( |
113 | from_name, | 118 | from_name, |
114 | from_address, | 119 | from_address, |
115 | to_name, | 120 | to_name, |
@@ -125,12 +130,13 @@ BOOL send_mail(const char* from_name, const char* from_address, | |||
125 | { | 130 | { |
126 | message_str = message; | 131 | message_str = message; |
127 | } | 132 | } |
128 | bool rv = send_mail(header, message_str, to_address, from_address); | 133 | bool rv = send(header, message_str, to_address, from_address); |
129 | if(rv) return TRUE; | 134 | if(rv) return TRUE; |
130 | return FALSE; | 135 | return FALSE; |
131 | } | 136 | } |
132 | 137 | ||
133 | void init_mail(const std::string& hostname, apr_pool_t* pool) | 138 | // static |
139 | void LLMail::init(const std::string& hostname, apr_pool_t* pool) | ||
134 | { | 140 | { |
135 | gMailSocket = NULL; | 141 | gMailSocket = NULL; |
136 | if(hostname.empty() || !pool) | 142 | if(hostname.empty() || !pool) |
@@ -157,12 +163,14 @@ void init_mail(const std::string& hostname, apr_pool_t* pool) | |||
157 | } | 163 | } |
158 | } | 164 | } |
159 | 165 | ||
160 | void enable_mail(bool mail_enabled) | 166 | // static |
167 | void LLMail::enable(bool mail_enabled) | ||
161 | { | 168 | { |
162 | gMailEnabled = mail_enabled; | 169 | gMailEnabled = mail_enabled; |
163 | } | 170 | } |
164 | 171 | ||
165 | std::string build_smtp_transaction( | 172 | // static |
173 | std::string LLMail::buildSMTPTransaction( | ||
166 | const char* from_name, | 174 | const char* from_name, |
167 | const char* from_address, | 175 | const char* from_address, |
168 | const char* to_name, | 176 | const char* to_name, |
@@ -216,7 +224,8 @@ std::string build_smtp_transaction( | |||
216 | return header.str(); | 224 | return header.str(); |
217 | } | 225 | } |
218 | 226 | ||
219 | bool send_mail( | 227 | // static |
228 | bool LLMail::send( | ||
220 | const std::string& header, | 229 | const std::string& header, |
221 | const std::string& message, | 230 | const std::string& message, |
222 | const char* from_address, | 231 | const char* from_address, |
@@ -309,3 +318,40 @@ bool send_mail( | |||
309 | #endif | 318 | #endif |
310 | return true; | 319 | return true; |
311 | } | 320 | } |
321 | |||
322 | |||
323 | // static | ||
324 | std::string LLMail::encryptIMEmailAddress(const LLUUID& from_agent_id, | ||
325 | const LLUUID& to_agent_id, | ||
326 | U32 time, | ||
327 | const U8* secret, | ||
328 | size_t secret_size) | ||
329 | { | ||
330 | #if LL_WINDOWS | ||
331 | return "blowfish-not-supported-on-windows"; | ||
332 | #else | ||
333 | size_t data_size = 4 + UUID_BYTES + UUID_BYTES; | ||
334 | // Convert input data into a binary blob | ||
335 | std::vector<U8> data; | ||
336 | data.resize(data_size); | ||
337 | // *NOTE: This may suffer from endian issues. Could be htonmemcpy. | ||
338 | memcpy(&data[0], &time, 4); | ||
339 | memcpy(&data[4], &from_agent_id.mData[0], UUID_BYTES); | ||
340 | memcpy(&data[4 + UUID_BYTES], &to_agent_id.mData[0], UUID_BYTES); | ||
341 | |||
342 | // Encrypt the blob | ||
343 | LLBlowfishCipher cipher(secret, secret_size); | ||
344 | size_t encrypted_size = cipher.requiredEncryptionSpace(data.size()); | ||
345 | U8* encrypted = new U8[encrypted_size]; | ||
346 | cipher.encrypt(&data[0], data_size, encrypted, encrypted_size); | ||
347 | |||
348 | std::string address = LLBase32::encode(encrypted, encrypted_size); | ||
349 | |||
350 | // Make it more pretty for humans. | ||
351 | LLString::toLower(address); | ||
352 | |||
353 | delete [] encrypted; | ||
354 | |||
355 | return address; | ||
356 | #endif | ||
357 | } | ||