From: Sebastian B. <sb...@us...> - 2013-01-02 17:45:34
|
Update of /cvsroot/simplemail/simplemail In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv20042 Modified Files: mail.h simplemail.h simplemail.c mail.c Log Message: Added possibility to compose a new mail using a defined body. Added BODY/K in MAILWRITE. Index: simplemail.h =================================================================== RCS file: /cvsroot/simplemail/simplemail/simplemail.h,v retrieving revision 1.93 retrieving revision 1.94 diff -u -d -r1.93 -r1.94 --- simplemail.h 23 Dec 2012 09:29:24 -0000 1.93 +++ simplemail.h 2 Jan 2013 17:45:31 -0000 1.94 @@ -80,6 +80,7 @@ void callback_write_mail_to(struct addressbook_entry_new *address); int callback_write_mail_to_str(char *str, char *subject); +int callback_write_mail_to_str_with_body(char *str, char *subject, char *body); void callback_imap_submit_folders(struct folder *f, struct list *list); void callback_imap_get_folders(struct folder *f); Index: simplemail.c =================================================================== RCS file: /cvsroot/simplemail/simplemail/simplemail.c,v retrieving revision 1.231 retrieving revision 1.232 diff -u -d -r1.231 -r1.232 --- simplemail.c 23 Dec 2012 09:29:24 -0000 1.231 +++ simplemail.c 2 Jan 2013 17:45:31 -0000 1.232 @@ -383,16 +383,17 @@ * @param to * @param replyto * @param subject + * @param body * @return the newly openend compose window number. */ -int callback_write_mail(char *from, char *to, char *replyto, char *subject) +static int callback_write_mail(char *from, char *to, char *replyto, char *subject, char *body) { struct compose_args ca; int win_num; memset(&ca,0,sizeof(ca)); ca.action = COMPOSE_ACTION_NEW; - ca.to_change = mail_create_for(from,to,replyto,subject); + ca.to_change = mail_create_for(from,to,replyto,subject,body); win_num = compose_window_open(&ca); @@ -410,7 +411,13 @@ /* a new mail should be written to a given address string */ int callback_write_mail_to_str(char *str, char *subject) { - return callback_write_mail(NULL,str,NULL,subject); + return callback_write_mail(NULL,str,NULL,subject,NULL); +} + +/* a new mail should be written to a given address string */ +int callback_write_mail_to_str_with_body(char *str, char *subject, char *body) +{ + return callback_write_mail(NULL,str,NULL,subject,body); } /** @@ -479,7 +486,7 @@ { struct folder *f = main_get_folder(); if (!f) return; - callback_write_mail(f->def_from,f->def_to,f->def_replyto,NULL); + callback_write_mail(f->def_from,f->def_to,f->def_replyto,NULL,NULL); } /* reply this mail */ Index: mail.h =================================================================== RCS file: /cvsroot/simplemail/simplemail/mail.h,v retrieving revision 1.82 retrieving revision 1.83 diff -u -d -r1.82 -r1.83 --- mail.h 11 Dec 2012 18:45:23 -0000 1.82 +++ mail.h 2 Jan 2013 17:45:31 -0000 1.83 @@ -189,7 +189,7 @@ void mail_identify_status(struct mail_info *m); struct mail_complete *mail_complete_create(void); -struct mail_complete *mail_create_for(char *from, char *to_str_unexpanded, char *replyto, char *subject); +struct mail_complete *mail_create_for(char *from, char *to_str_unexpanded, char *replyto, char *subject, char *body); struct mail *mail_create_from_file(char *filename); struct mail_complete *mail_complete_create_from_file(char *filename); struct mail_complete *mail_create_reply(int num, struct mail_complete **mail_array); Index: mail.c =================================================================== RCS file: /cvsroot/simplemail/simplemail/mail.c,v retrieving revision 1.243 retrieving revision 1.244 diff -u -d -r1.243 -r1.244 --- mail.c 23 Dec 2012 20:19:14 -0000 1.243 +++ mail.c 2 Jan 2013 17:45:31 -0000 1.244 @@ -990,11 +990,18 @@ return NULL; } -/************************************************************************** - Creates a mail to be send to a given address (fills out the to field - and the contents) -**************************************************************************/ -struct mail_complete *mail_create_for(char *from, char *to_str_unexpanded, char *replyto, char *subject) +/** + * Creates a mail to be send to a given address (fills out the to field + * and the body). + * + * @param from + * @param to_str_unexpanded + * @param replyto + * @param subject + * @param body maybe NULL in which case the best phrase is used + * @return + */ +struct mail_complete *mail_create_for(char *from, char *to_str_unexpanded, char *replyto, char *subject, char *body) { struct mail_complete *mail; char *to_str; @@ -1008,7 +1015,6 @@ if ((mail = mail_complete_create())) { string contents_str; - struct phrase *phrase; if (!(string_initialize(&contents_str,100))) { @@ -1017,8 +1023,6 @@ return NULL; } - phrase = phrase_find_best(to_str); - if (from) { mail_complete_add_header(mail,"From",4,from,strlen(from),0); @@ -1066,42 +1070,50 @@ } } - if (mb.phrase) + if (body) { - if (phrase && phrase->write_welcome_repicient) + string_append(&contents_str,body); + } else + { + struct phrase *phrase; + phrase = phrase_find_best(to_str); + if (mb.phrase) { - char *str = mail_create_string(phrase->write_welcome_repicient, NULL, mb.phrase, mb.addr_spec); - if (str) + if (phrase && phrase->write_welcome_repicient) { - string_append(&contents_str,str); - string_append(&contents_str,"\n"); - free(str); + char *str = mail_create_string(phrase->write_welcome_repicient, NULL, mb.phrase, mb.addr_spec); + if (str) + { + string_append(&contents_str,str); + string_append(&contents_str,"\n"); + free(str); + } + } + } else + { + if (phrase && phrase->write_welcome) + { + char *str = mail_create_string(phrase->write_welcome, NULL, NULL, NULL); + if (str) + { + string_append(&contents_str,str); + string_append(&contents_str,"\n"); + free(str); + } } } - } else - { - if (phrase && phrase->write_welcome) + + if (phrase && phrase->write_closing) { - char *str = mail_create_string(phrase->write_welcome, NULL, NULL, NULL); + char *str = mail_create_string(phrase->write_closing, NULL, NULL, NULL); if (str) { string_append(&contents_str,str); - string_append(&contents_str,"\n"); free(str); } } } - if (phrase && phrase->write_closing) - { - char *str = mail_create_string(phrase->write_closing, NULL, NULL, NULL); - if (str) - { - string_append(&contents_str,str); - free(str); - } - } - mail->decoded_data = contents_str.str; mail->decoded_len = contents_str.len; mail_process_headers(mail); |