1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
|
/* $Cambridge: hermes/src/prayer/cmd/cmd_printable.c,v 1.10 2010/07/08 16:55:49 dpc22 Exp $ */
/************************************************
* Prayer - a Webmail Interface *
************************************************/
/* Copyright (c) University of Cambridge 2000 - 2008 */
/* See the file NOTICE for conditions of use and distribution. */
#include "prayer_session.h"
void cmd_printable(struct session *session)
{
struct template_vals *tvals = session->template_vals;
struct options *options = session->options;
struct prefs *prefs = options->prefs;
struct request *request = session->request;
struct msgmap *zm = session->zm;
unsigned long msgno, msguid;
char *section;
struct buffer *b = request->write_buffer;
MAILSTREAM *stream = session->stream;
BOOL html_show_images = prefs->html_remote_images;
if (!msgmap_update(zm)) {
session_alert(session, "Failed to update msgmap");
session_redirect(session, request, "restart");
return;
}
if (msgmap_size(zm) == 0) {
session_message(session, "Folder is empty");
session_redirect(session, request, "list");
return;
}
/* Save options if anything changed */
if (options->save)
session_streams_save_options(session);
/* Record last command for compose/cancel and friends */
if (!session->draft->have_draft)
session->compose_parent_cmd = "display";
/* Record last command for save/cancel */
session->copy_parent_cmd = "display";
/* Record last command for addressbook take */
session->take_parent_cmd = "display";
if ((request->argc == 5) && !strcmp(request->argv[4], "show_images"))
html_show_images = T;
section = NIL;
if (request->argc >= 4)
section = request->argv[3];
if (request->argc >= 3) {
msgno = atoi(request->argv[1]);
msguid = atoi(request->argv[2]);
if (!(msgno = stream_check_uid(session, stream, msgno, msguid))) {
session_redirect(session, request, "list");
return;
}
} else {
msgno = session->last_displayed;
if ((msgno == 0) || (msgno > msgmap_size(zm)))
msgno = msgmap_value(zm, msgmap_size(zm));
msguid = ml_uid(session, stream, msgno);
}
session->current = msgno;
session->last_displayed = msgno;
display_addnav(session, stream, msgno);
display_addhdrs(session, stream, msgno);
session_seed_template(session, tvals);
template_expand("printable", tvals, b);
if (!display_body(session, request, stream, msgno, section,
"printable", html_show_images)) {
session_redirect(session, request, "restart");
return;
}
template_expand("printable_tail", tvals, b);
/* Send out the response */
response_html(request, 200);
}
|