Commit e7730fe5 e7730fe57706ff1369892883141b696b292ad353 by Sergey Poznyakoff

Handle Fcc headers.

1 parent 5ea83ef7
...@@ -34,6 +34,9 @@ ...@@ -34,6 +34,9 @@
34 #include <mailutils/registrar.h> 34 #include <mailutils/registrar.h>
35 #include <mailutils/stream.h> 35 #include <mailutils/stream.h>
36 #include <mailutils/url.h> 36 #include <mailutils/url.h>
37 #include <mailutils/header.h>
38 #include <mailutils/mailbox.h>
39 #include <mailutils/message.h>
37 40
38 #include <mailer0.h> 41 #include <mailer0.h>
39 42
...@@ -259,8 +262,45 @@ mailer_check_to (address_t to) ...@@ -259,8 +262,45 @@ mailer_check_to (address_t to)
259 return 0; 262 return 0;
260 } 263 }
261 264
265 static void
266 save_fcc (message_t msg)
267 {
268 header_t hdr;
269 size_t count = 0, i;
270 char buf[512];
271
272 if (message_get_header (msg, &hdr))
273 return;
274
275 if (header_get_value (hdr, MU_HEADER_FCC, NULL, 0, NULL))
276 return;
277
278 header_get_field_count (hdr, &count);
279 for (i = 1; i <= count; i++)
280 {
281 mailbox_t mbox;
282
283 header_get_field_name (hdr, i, buf, sizeof buf, NULL);
284 if (strcasecmp (buf, MU_HEADER_FCC) == 0)
285 {
286 if (header_get_field_value (hdr, i, buf, sizeof buf, NULL))
287 continue;
288 if (mailbox_create_default (&mbox, buf))
289 continue; /*FIXME: error message?? */
290 if (mailbox_open (mbox, MU_STREAM_RDWR|MU_STREAM_CREAT|MU_STREAM_APPEND) == 0)
291 {
292 mailbox_append_message (mbox, msg);
293 mailbox_flush (mbox, 0);
294 }
295 mailbox_close (mbox);
296 mailbox_destroy (&mbox);
297 }
298 }
299 }
300
262 int 301 int
263 mailer_send_message (mailer_t mailer, message_t msg, address_t from, address_t to) 302 mailer_send_message (mailer_t mailer, message_t msg,
303 address_t from, address_t to)
264 { 304 {
265 int status; 305 int status;
266 306
...@@ -282,7 +322,8 @@ mailer_send_message (mailer_t mailer, message_t msg, address_t from, address_t t ...@@ -282,7 +322,8 @@ mailer_send_message (mailer_t mailer, message_t msg, address_t from, address_t t
282 if ((status = mailer_check_to (to)) != 0) 322 if ((status = mailer_check_to (to)) != 0)
283 return status; 323 return status;
284 } 324 }
285 325
326 save_fcc (msg);
286 return mailer->_send_message (mailer, msg, from, to); 327 return mailer->_send_message (mailer, msg, from, to);
287 } 328 }
288 329
......