| %s URL | ", loc("Logbook"));
@@ -18298,14 +18263,33 @@ void format_email_html(LOGBOOK * lbs, char *mail_to, int message_id,
/*------------------------------------------------------------------*/
+void format_email_html2(LOGBOOK * lbs, char *mail_to, int message_id,
+ char attrib[MAX_N_ATTR][NAME_LENGTH], char *mail_param, int old_mail,
+ char att_file[MAX_ATTACHMENTS][256], char *encoding, char *url, char *mail_text)
+{
+ char str[256], *p;
+
+ sprintf(str, "%d", message_id);
+
+ strlen_retbuf = 0;
+ show_elog_entry(lbs, str, "email");
+ p = strstr(return_buffer, "\r\n\r\n");
+ if (p)
+ strlcpy(mail_text + strlen(mail_text), p+4, TEXT_SIZE + 1000 - strlen(mail_text));
+ strlen_retbuf = 0;
+}
+
+/*------------------------------------------------------------------*/
+
int compose_email(LOGBOOK * lbs, char *mail_to, int message_id,
char attrib[MAX_N_ATTR][NAME_LENGTH], char *mail_param, int old_mail,
char att_file[MAX_ATTACHMENTS][256], char *encoding)
{
- int i, n, flags, status, html = 0;
+ int i, n, flags, status, mail_encoding;
char str[NAME_LENGTH + 100], mail_from[256], *mail_text, smtp_host[256],
subject[256], error[256], content_type[256];
char list[MAX_PARAM][NAME_LENGTH], url[256];
+ char slist[MAX_N_ATTR + 10][NAME_LENGTH], svalue[MAX_N_ATTR + 10][NAME_LENGTH];
if (!getcfg("global", "SMTP host", smtp_host, sizeof(smtp_host))) {
show_error(loc("No SMTP host defined in [global] section of configuration file"));
@@ -18317,33 +18301,49 @@ int compose_email(LOGBOOK * lbs, char *mail_to, int message_id,
flags = atoi(str);
/* get initial HTML flag from message encoding */
+ mail_encoding = 1; // 1:text, 2:short HTML, 4:full HTML
if (encoding[0] == 'E' || encoding[0] == 'H')
- html = 1;
+ mail_encoding = 2;
/* overwrite with config setting */
- if (getcfg(lbs->name, "Email encoding", str, sizeof(str))) {
- if (atoi(str) == 1)
- html = 0;
- else if (atoi(str) == 2)
- html = 1;
- }
+ if (getcfg(lbs->name, "Email encoding", str, sizeof(str)))
+ mail_encoding = atoi(str);
retrieve_email_from(lbs, mail_from, attrib);
+ /* compose subject from attributes */
+ if (getcfg(lbs->name, "Use Email Subject", subject, sizeof(subject))) {
+ i = build_subst_list(lbs, slist, svalue, attrib, TRUE);
+ sprintf(str, "%d", message_id);
+ add_subst_list(slist, svalue, "message id", str, &i);
+ strsubst(subject, sizeof(subject), slist, svalue, i);
+ } else {
+ if (old_mail)
+ strcpy(subject, "Updated ELOG entry");
+ else
+ strcpy(subject, "New ELOG entry");
+ }
+
+ compose_base_url(lbs, str, sizeof(str));
+ sprintf(url, "%s%d", str, message_id);
+
mail_text = xmalloc(TEXT_SIZE + 1000);
mail_text[0] = 0;
- if (html)
- format_email_html(lbs, mail_to, message_id, attrib, mail_param, old_mail, att_file, encoding,
- mail_text);
- else
+ if (mail_encoding & 1)
format_email_text(lbs, mail_to, message_id, attrib, mail_param, old_mail, att_file, encoding,
- mail_text);
+ url, mail_text);
+ else if (mail_encoding & 2)
+ format_email_html(lbs, mail_to, message_id, attrib, mail_param, old_mail, att_file, encoding,
+ url, mail_text);
+ else if (mail_encoding & 4)
+ format_email_html2(lbs, mail_to, message_id, attrib, mail_param, old_mail, att_file, encoding,
+ url, mail_text);
- if (html)
- strcpy(content_type, "text/html");
- else
+ if (mail_encoding & 1)
strcpy(content_type, "text/plain");
+ else
+ strcpy(content_type, "text/html");
status = 0;
if (flags & 16) {
@@ -19472,7 +19472,7 @@ void show_elog_entry(LOGBOOK * lbs, char *dec_path, char *command)
gattr[MAX_N_ATTR][NAME_LENGTH], svalue[MAX_N_ATTR + 10][NAME_LENGTH], *p,
lbk_list[MAX_N_LIST][NAME_LENGTH], comment[256], class_name[80], class_value[80], fl[8][NAME_LENGTH];
FILE *f;
- BOOL first, show_text, display_inline, subtable;
+ BOOL first, show_text, display_inline, subtable, email;
struct tm *pts;
struct stat st;
time_t ltime;
@@ -19480,6 +19480,7 @@ void show_elog_entry(LOGBOOK * lbs, char *dec_path, char *command)
message_id = atoi(dec_path);
message_error = EL_SUCCESS;
_current_message_id = message_id;
+ email = strieq(command, "email");
/* check for guest access */
if (!getcfg(lbs->name, "Guest Menu commands", menu_str, sizeof(menu_str))
@@ -19656,136 +19657,139 @@ void show_elog_entry(LOGBOOK * lbs, char *dec_path, char *command)
/*---- title ----*/
- show_standard_title(lbs->name, "", 0);
+ if (!email)
+ show_standard_title(lbs->name, "", 0);
/*---- menu buttons ----*/
- rsprintf(" |