Commit d12dd7c90310874032aac827c829712b2ca08ec7
1 parent
457fc6c9
[IMP] replace string by file_ref in compose_mail
Showing
1 changed file
with
12 additions
and
53 deletions
Show diff stats
mail/compose_email.anubis
| @@ -115,40 +115,6 @@ define Maybe($T) | @@ -115,40 +115,6 @@ define Maybe($T) | ||
| 115 | } | 115 | } |
| 116 | }. | 116 | }. |
| 117 | 117 | ||
| 118 | - define Maybe(String) | ||
| 119 | - day_name | ||
| 120 | - ( | ||
| 121 | - Int day_num | ||
| 122 | - )= | ||
| 123 | - if day_num = 1 then success("Mon") | ||
| 124 | - else if day_num = 2 then success("Tue") | ||
| 125 | - else if day_num = 3 then success("Wed") | ||
| 126 | - else if day_num = 4 then success("Thu") | ||
| 127 | - else if day_num = 5 then success("Fri") | ||
| 128 | - else if day_num = 6 then success("Sat") | ||
| 129 | - else if day_num = 7 then success("Sun") | ||
| 130 | - else failure | ||
| 131 | - . | ||
| 132 | - | ||
| 133 | - define Maybe(String) | ||
| 134 | - month_name | ||
| 135 | - ( | ||
| 136 | - Int month_num | ||
| 137 | - )= | ||
| 138 | - if month_num = 1 then success("Jan") | ||
| 139 | - else if month_num = 2 then success("Feb") | ||
| 140 | - else if month_num = 3 then success("Mar") | ||
| 141 | - else if month_num = 4 then success("Apr") | ||
| 142 | - else if month_num = 5 then success("May") | ||
| 143 | - else if month_num = 6 then success("Jun") | ||
| 144 | - else if month_num = 7 then success("Jul") | ||
| 145 | - else if month_num = 8 then success("Aug") | ||
| 146 | - else if month_num = 9 then success("Sep") | ||
| 147 | - else if month_num = 10 then success("Oct") | ||
| 148 | - else if month_num = 11 then success("Nov") | ||
| 149 | - else if month_num = 12 then success("Dec") | ||
| 150 | - else failure | ||
| 151 | - . | ||
| 152 | 118 | ||
| 153 | public define String | 119 | public define String |
| 154 | address_to_string | 120 | address_to_string |
| @@ -239,24 +205,17 @@ public define String | @@ -239,24 +205,17 @@ public define String | ||
| 239 | define String | 205 | define String |
| 240 | data_file_multipart | 206 | data_file_multipart |
| 241 | ( | 207 | ( |
| 242 | - String attached_file, | 208 | + File_ref file, |
| 243 | )= | 209 | )= |
| 244 | - | ||
| 245 | - if (Maybe(RStream))file(attached_file, read) is | ||
| 246 | - { | ||
| 247 | - failure then | ||
| 248 | - data_file_multipart(attached_file, constant_byte_array(0,0)) | ||
| 249 | - success(fd) then | ||
| 250 | - with data_file = if reliable_read(fd, file_size(attached_file), 100) is | 210 | + with data_file = if read_from_file(file.path +"/"+file.name) is |
| 251 | { | 211 | { |
| 252 | - failure then constant_byte_array(0,0), | ||
| 253 | - success(data) then data | ||
| 254 | - }, | ||
| 255 | - | ||
| 256 | - data_file_multipart(attached_file, data_file) | 212 | + cannot_find_file then constant_byte_array(0,0), |
| 213 | + read_error(data) then data | ||
| 214 | + ok(data) then data | ||
| 215 | + }, | ||
| 216 | + data_file_multipart(file.name, data_file) | ||
| 217 | +. | ||
| 257 | 218 | ||
| 258 | - } | ||
| 259 | -. | ||
| 260 | if file(fullpath, read) is | 219 | if file(fullpath, read) is |
| 261 | { | 220 | { |
| 262 | failure then | 221 | failure then |
| @@ -267,8 +226,7 @@ define String | @@ -267,8 +226,7 @@ define String | ||
| 267 | define String | 226 | define String |
| 268 | data_files_multipart | 227 | data_files_multipart |
| 269 | ( | 228 | ( |
| 270 | - //List(File_Attached) files, | ||
| 271 | - List(String) files, | 229 | + List(File_ref) files, |
| 272 | String boundary | 230 | String boundary |
| 273 | )= | 231 | )= |
| 274 | if files is | 232 | if files is |
| @@ -277,7 +235,8 @@ define String | @@ -277,7 +235,8 @@ define String | ||
| 277 | [file_j . t] then | 235 | [file_j . t] then |
| 278 | "--" + boundary + crlf + | 236 | "--" + boundary + crlf + |
| 279 | data_file_multipart(file_j) + data_files_multipart(t, boundary) | 237 | data_file_multipart(file_j) + data_files_multipart(t, boundary) |
| 280 | - }. | 238 | + } |
| 239 | +. | ||
| 281 | 240 | ||
| 282 | 241 | ||
| 283 | public define String | 242 | public define String |
| @@ -399,7 +358,7 @@ public define String | @@ -399,7 +358,7 @@ public define String | ||
| 399 | "Message-ID: " + to_ascii(sha1((from, send_date))) + crlf + | 358 | "Message-ID: " + to_ascii(sha1((from, send_date))) + crlf + |
| 400 | "Date: " + send_date + crlf + | 359 | "Date: " + send_date + crlf + |
| 401 | // "From: " + user.login + "<" + user.login + "@" + domain + ">" + crlf + | 360 | // "From: " + user.login + "<" + user.login + "@" + domain + ">" + crlf + |
| 402 | - "User-Agent: Calexium lib email sender" + crlf + | 361 | + "User-Agent: Anubis XLib email sender" + crlf + |
| 403 | "From: " + "<" + from.address + ">" + crlf + | 362 | "From: " + "<" + from.address + ">" + crlf + |
| 404 | (if reply_to = "" then | 363 | (if reply_to = "" then |
| 405 | "" | 364 | "" |