Functions which deal with the fetching and displaying of messages.
[Display some mime types through webcit]


Data Structures

struct  addrbookent
struct  attach_link

Defines

#define SUBJ_COL_WIDTH_PCT   50
#define SENDER_COL_WIDTH_PCT   30
#define DATE_PLUS_BUTTONS_WIDTH_PCT   20

Functions

iconv_t ctdl_iconv_open (const char *tocode, const char *fromcode)
 Wrapper around iconv_open() Our version adds aliases for non-standard Microsoft charsets such as 'MS950', aliasing them to names like 'CP950'.
void utf8ify_rfc822_string (char *buf)
 Handle subjects with RFC2047 encoding such as: =?koi8-r?B?78bP0s3Mxc7JxSDXz9rE1dvO2c3JINvB0sHNySDP?=.
void rfc2047encode (char *target, int maxlen, char *source)
 RFC2047-encode a header field if necessary. If no non-ASCII characters are found, the string will be copied verbatim without encoding.
void url (char *buf)
 Look for URL's embedded in a buffer and make them linkable. We use a target window in order to keep the BBS session in its own window.
void vcard_n_prettyize (char *name)
 Turn a vCard "n" (name) field into something displayable.
void fetchname_parsed_vcard (struct vCard *v, char *storename)
 preparse a vcard name display_vcard() calls this after parsing the textual vCard into our 'struct vCard' data object. This gets called instead of display_parsed_vcard() if we are only looking to extract the person's name instead of displaying the card.
void display_parsed_vcard (struct vCard *v, int full)
 html print a vcard display_vcard() calls this after parsing the textual vCard into our 'struct vCard' data object.
void display_vcard (char *vcard_source, char alpha, int full, char *storename)
 Display a textual vCard (Converts to a vCard object and then calls the actual display function) Set 'full' to nonzero to display the whole card instead of a one-liner. Or, if "storename" is non-NULL, just store the person's name in that buffer instead of displaying the card at all.
void read_message (long msgnum, int printable_view, char *section)
 I wanna SEE that message!
void embed_message (char *msgnum_as_string)
 Unadorned HTML output of an individual message, suitable for placing in a hidden iframe, for printing, or whatever.
void print_message (char *msgnum_as_string)
 Printable view of a message.
void display_headers (char *msgnum_as_string)
 Display a message's headers.
void pullquote_message (long msgnum, int forward_attachments, int include_headers)
 Read message in simple, JavaScript-embeddable form for 'forward' or 'reply quoted' operations.
void display_summarized (int num)
 Display one row in the mailbox summary view.
void display_addressbook (long msgnum, char alpha)
 display the adressbook overview
void lastfirst_firstlast (char *namebuf)
 If it's an old "Firstname Lastname" style record, try to convert it.
void fetch_ab_name (long msgnum, char *namebuf)
 fetch what??? name
int abcmp (const void *ab1, const void *ab2)
 Record compare function for sorting address book indices.
void nametab (char *tabbuf, char *name)
 Helper function for do_addrbook_view() Converts a name into a three-letter tab label.
void do_addrbook_view (struct addrbookent *addrbook, int num_ab)
 Render the address book using info we gathered during the scan.
int load_msg_ptrs (char *servcmd, int with_headers)
 load message pointers from the server
int longcmp_r (const void *s1, const void *s2)
 qsort() compatible function to compare two longs in descending order.
int summcmp_subj (const void *s1, const void *s2)
 qsort() compatible function to compare two message summary structs by ascending subject.
int summcmp_rsubj (const void *s1, const void *s2)
 qsort() compatible function to compare two message summary structs by descending subject.
int summcmp_sender (const void *s1, const void *s2)
 qsort() compatible function to compare two message summary structs by ascending sender.
int summcmp_rsender (const void *s1, const void *s2)
 qsort() compatible function to compare two message summary structs by descending sender.
int summcmp_date (const void *s1, const void *s2)
 qsort() compatible function to compare two message summary structs by ascending date.
int summcmp_rdate (const void *s1, const void *s2)
 qsort() compatible function to compare two message summary structs by descending date.
void readloop (char *oper)
 command loop for reading messages
void post_mime_to_server (void)
 Back end for post_message() ... this is where the actual message gets transmitted to the server.
void post_message (void)
 Post message (or don't post message).
void display_enter (void)
 display the message entry screen
void delete_msg (void)
 delete a message
void move_msg (void)
 move a message to another folder
void confirm_move_msg (void)
 Confirm move of a message.

Define Documentation

#define SUBJ_COL_WIDTH_PCT   50

Mailbox view column width

Definition at line 15 of file messages.c.

Referenced by display_summarized().

#define SENDER_COL_WIDTH_PCT   30

Mailbox view column width

Definition at line 16 of file messages.c.

Referenced by display_summarized().

#define DATE_PLUS_BUTTONS_WIDTH_PCT   20

Mailbox view column width

Definition at line 17 of file messages.c.

Referenced by display_summarized().


Function Documentation

iconv_t ctdl_iconv_open ( const char *  tocode,
const char *  fromcode 
)

Wrapper around iconv_open() Our version adds aliases for non-standard Microsoft charsets such as 'MS950', aliasing them to names like 'CP950'.

Parameters:
tocode Target encoding
fromcode Source encoding

Definition at line 40 of file messages.c.

References safestrncpy().

Referenced by display_rss(), output_html(), pullquote_message(), read_message(), and utf8ify_rfc822_string().

void utf8ify_rfc822_string ( char *  buf  ) 

Handle subjects with RFC2047 encoding such as: =?koi8-r?B?78bP0s3Mxc7JxSDXz9rE1dvO2c3JINvB0sHNySDP?=.

Parameters:
buf the stringbuffer to process

< Buffer of characters to be converted

< Buffer for converted characters

< Length of input buffer

< Length of output buffer

< Saved pointer to input buffer

< Saved pointer to output buffer

Sometimes, badly formed messages contain strings which were simply written out directly in some foreign character set instead of using RFC2047 encoding. This is illegal but we will attempt to handle it anyway by converting from a user-specified default charset to UTF-8 if we see any nonprintable characters.

Now we handle foreign character sets properly encoded in RFC2047 format.

< base64

< quoted-printable

< unknown encoding

Since spammers will go to all sorts of absurd lengths to get their messages through, there are LOTS of corrupt headers out there. So, prevent a really badly formed RFC2047 header from throwing this function into an infinite loop.

Definition at line 63 of file messages.c.

References ctdl_iconv_open(), CtdlDecodeBase64(), CtdlDecodeQuotedPrintable(), extract_token(), get_preference(), remove_token(), safestrncpy(), and snprintf().

Referenced by display_rss(), load_msg_ptrs(), pullquote_message(), and read_message().

void rfc2047encode ( char *  target,
int  maxlen,
char *  source 
)

RFC2047-encode a header field if necessary. If no non-ASCII characters are found, the string will be copied verbatim without encoding.

Parameters:
target Target buffer.
maxlen Maximum size of target buffer.
source Source string to be encoded.

Definition at line 211 of file messages.c.

References safestrncpy().

Referenced by post_message().

void url ( char *  buf  ) 

Look for URL's embedded in a buffer and make them linkable. We use a target window in order to keep the BBS session in its own window.

Parameters:
buf the message buffer

Definition at line 252 of file messages.c.

Referenced by display_rss(), fmout(), is_bogus(), pullquote_message(), and read_message().

void vcard_n_prettyize ( char *  name  ) 

Turn a vCard "n" (name) field into something displayable.

Parameters:
name the name field to convert

Definition at line 308 of file messages.c.

Referenced by display_parsed_vcard(), and do_addrbook_view().

void fetchname_parsed_vcard ( struct vCard v,
char *  storename 
)

preparse a vcard name display_vcard() calls this after parsing the textual vCard into our 'struct vCard' data object. This gets called instead of display_parsed_vcard() if we are only looking to extract the person's name instead of displaying the card.

Parameters:
v the vcard to retrieve the name from
storename where to put the name at

Definition at line 349 of file messages.c.

References vcard_get_prop().

Referenced by display_vcard().

void display_parsed_vcard ( struct vCard v,
int  full 
)

html print a vcard display_vcard() calls this after parsing the textual vCard into our 'struct vCard' data object.

Set 'full' to nonzero to display the full card, otherwise it will only show a summary line.

This code is a bit ugly, so perhaps an explanation is due: we do this in two passes through the vCard fields. On the first pass, we process fields we understand, and then render them in a pretty fashion at the end. Then we make a second pass, outputting all the fields we don't understand in a simple two-column name/value format.

Parameters:
v the vCard to display
full display all items of the vcard?

Various fields we may encounter

N is name, but only if there's no FN already there

FN (full name) is a true 'display name' field

title

organization

Definition at line 380 of file messages.c.

References CtdlDecodeBase64(), CtdlDecodeQuotedPrintable(), escputs(), extract_token(), vCard::vCardProp::name, num_tokens(), vCard::numprops, vCard::prop, remove_token(), stresc(), urlesc(), vCard::vCardProp::value, vcard_get_prop(), vcard_n_prettyize(), and wprintf().

Referenced by display_vcard().

void display_vcard ( char *  vcard_source,
char  alpha,
int  full,
char *  storename 
)

Display a textual vCard (Converts to a vCard object and then calls the actual display function) Set 'full' to nonzero to display the whole card instead of a one-liner. Or, if "storename" is non-NULL, just store the person's name in that buffer instead of displaying the card at all.

Parameters:
vcard_source the buffer containing the vcard text
alpha what???
full should we usse all lines?
storename where to store???

Definition at line 609 of file messages.c.

References display_parsed_vcard(), fetchname_parsed_vcard(), vcard_free(), vcard_get_prop(), and vcard_load().

Referenced by display_addressbook(), fetch_ab_name(), and read_message().

void read_message ( long  msgnum,
int  printable_view,
char *  section 
)

I wanna SEE that message!

Parameters:
msgnum the citadel number of the message to display
printable_view are we doing a print view?
section Optional for encapsulated message/rfc822 submessage)

< Buffer of characters to be converted

< Buffer for converted characters

< Length of input buffer

< Length of output buffer

< Saved pointer to output buffer

begin everythingamundo table

begin message header table

begin handler prep

end handler prep

Generate a reply-to address

start msg buttons

Reply

ReplyQuoted

ReplyAll

Forward

If this is one of my own rooms, or if I'm an Aide or Room Aide, I can move/delete

Move

Delete

Headers

Print

Begin body

Learn the content type

Set up a character set conversion if we need to (and if we can)

Messages in legacy Citadel variformat get handled thusly...

Boring old 80-column fixed format text gets handled this way...

HTML is fun, but we've got to strip it first

Unknown weirdness

If there are attached submessages, display them now...

use printable_view to suppress buttons

Afterwards, offer links to download attachments 'n' such

Handler for vCard parts

If it's my vCard I can edit it

In all cases, display the full card

Handler for calendar parts

end everythingamundo table

Definition at line 650 of file messages.c.

References ctdl_iconv_open(), display_vcard(), escputs(), extract_int(), extract_token(), fmout(), fmt_date(), attach_link::html, load_mimepart(), lprintf(), num_tokens(), output_html(), attach_link::partnum, read_message(), safestrncpy(), serv_getln(), serv_printf(), snprintf(), striplt(), url(), urlescputs(), utf8ify_rfc822_string(), and wprintf().

Referenced by display_wiki_page(), embed_message(), print_message(), and read_message().

void embed_message ( char *  msgnum_as_string  ) 

Unadorned HTML output of an individual message, suitable for placing in a hidden iframe, for printing, or whatever.

Parameters:
msgnum_as_string Message number, as a string instead of as a long int

Definition at line 1206 of file messages.c.

References begin_ajax_response(), end_ajax_response(), and read_message().

Referenced by session_loop().

void print_message ( char *  msgnum_as_string  ) 

Printable view of a message.

Parameters:
msgnum_as_string Message number, as a string instead of as a long int

Definition at line 1221 of file messages.c.

References begin_burst(), output_headers(), read_message(), wDumpContent(), and wprintf().

Referenced by session_loop().

void display_headers ( char *  msgnum_as_string  ) 

Display a message's headers.

Parameters:
msgnum_as_string Message number, as a string instead of as a long int

Definition at line 1251 of file messages.c.

References begin_burst(), output_headers(), serv_getln(), serv_printf(), wDumpContent(), and wprintf().

Referenced by session_loop().

void pullquote_message ( long  msgnum,
int  forward_attachments,
int  include_headers 
)

Read message in simple, JavaScript-embeddable form for 'forward' or 'reply quoted' operations.

NOTE: it is VITALLY IMPORTANT that we output no single-quotes or linebreaks in this function. Doing so would throw a JavaScript error in the 'supplied text' argument to the editor.

Parameters:
msgnum Message number of the message we want to quote
forward_attachments Nonzero if we want attachments to be forwarded

< Buffer of characters to be converted

< Buffer for converted characters

< Length of input buffer

< Length of output buffer

< Saved pointer to output buffer

Save attachment info for later. We can't start downloading them yet because we're in the middle of a server transaction.

Begin body

Learn the content type

Set up a character set conversion if we need to (and if we can)

Messages in legacy Citadel variformat get handled thusly...

HTML just gets escaped and stuffed back into the editor

Unknown weirdness ... don't know how to handle this content type

end of body handler

Definition at line 1288 of file messages.c.

References wc_attachment::content_type, ctdl_iconv_open(), wc_attachment::data, extract_int(), extract_token(), wc_attachment::filename, fmt_date(), wc_attachment::length, load_mimepart(), lprintf(), msgescputs(), wc_attachment::next, pullquote_fmout(), safestrncpy(), serv_getln(), serv_printf(), url(), utf8ify_rfc822_string(), and wprintf().

Referenced by display_enter().

void display_summarized ( int  num  ) 

Display one row in the mailbox summary view.

Parameters:
num The row number to be displayed

Definition at line 1605 of file messages.c.

References DATE_PLUS_BUTTONS_WIDTH_PCT, escputs(), fmt_date(), SENDER_COL_WIDTH_PCT, SUBJ_COL_WIDTH_PCT, and wprintf().

void display_addressbook ( long  msgnum,
char  alpha 
)

display the adressbook overview

Parameters:
msgnum the citadel message number
alpha what????

Display the summary line

If it's my vCard I can edit it

Definition at line 1638 of file messages.c.

References display_vcard(), extract_int(), extract_token(), load_mimepart(), safestrncpy(), serv_getln(), serv_puts(), and wprintf().

void lastfirst_firstlast ( char *  namebuf  ) 

If it's an old "Firstname Lastname" style record, try to convert it.

Parameters:
namebuf name to analyze, reverse if nescessary

Definition at line 1703 of file messages.c.

References extract_token(), num_tokens(), and remove_token().

Referenced by fetch_ab_name().

void fetch_ab_name ( long  msgnum,
char *  namebuf 
)

fetch what??? name

Parameters:
msgnum the citadel message number
namebuf where to put the name in???

unfortunately we need the mime info now

Definition at line 1725 of file messages.c.

References display_vcard(), extract_int(), extract_token(), lastfirst_firstlast(), load_mimepart(), safestrncpy(), serv_getln(), serv_puts(), and striplt().

int abcmp ( const void *  ab1,
const void *  ab2 
)

Record compare function for sorting address book indices.

Parameters:
ab1 adressbook one
ab2 adressbook two

Definition at line 1790 of file messages.c.

Referenced by do_addrbook_view().

void nametab ( char *  tabbuf,
char *  name 
)

Helper function for do_addrbook_view() Converts a name into a three-letter tab label.

Parameters:
tabbuf the tabbuffer to add name to
name the name to add to the tabbuffer

Definition at line 1804 of file messages.c.

References stresc().

Referenced by do_addrbook_view().

void do_addrbook_view ( struct addrbookent addrbook,
int  num_ab 
)

Render the address book using info we gathered during the scan.

Parameters:
addrbook the addressbook to render
num_ab the number of the addressbook

Definition at line 1818 of file messages.c.

References abcmp(), begin_tab(), bstr(), end_tab(), escputs(), nametab(), tabbed_dialog(), vcard_n_prettyize(), and wprintf().

int load_msg_ptrs ( char *  servcmd,
int  with_headers 
)

load message pointers from the server

Parameters:
servcmd the citadel command to send to the citserver
with_headers what headers???

Handle subjects with RFC2047 encoding

Handle senders with RFC2047 encoding

Definition at line 1916 of file messages.c.

References extract_long(), extract_token(), safestrncpy(), serv_getln(), serv_puts(), and utf8ify_rfc822_string().

Referenced by calendar_section(), display_rss(), display_smtpqueue_inner_div(), readloop(), and tasks_section().

int longcmp_r ( const void *  s1,
const void *  s2 
)

qsort() compatible function to compare two longs in descending order.

Parameters:
s1 first number to compare
s2 second number to compare

Definition at line 2014 of file messages.c.

int summcmp_subj ( const void *  s1,
const void *  s2 
)

qsort() compatible function to compare two message summary structs by ascending subject.

Parameters:
s1 first item to compare
s2 second item to compare

Definition at line 2033 of file messages.c.

References message_summary::subj.

int summcmp_rsubj ( const void *  s1,
const void *  s2 
)

qsort() compatible function to compare two message summary structs by descending subject.

Parameters:
s1 first item to compare
s2 second item to compare

Definition at line 2048 of file messages.c.

References message_summary::subj.

int summcmp_sender ( const void *  s1,
const void *  s2 
)

qsort() compatible function to compare two message summary structs by ascending sender.

Parameters:
s1 first item to compare
s2 second item to compare

Definition at line 2063 of file messages.c.

References message_summary::from.

int summcmp_rsender ( const void *  s1,
const void *  s2 
)

qsort() compatible function to compare two message summary structs by descending sender.

Parameters:
s1 first item to compare
s2 second item to compare

Definition at line 2078 of file messages.c.

References message_summary::from.

int summcmp_date ( const void *  s1,
const void *  s2 
)

qsort() compatible function to compare two message summary structs by ascending date.

Parameters:
s1 first item to compare
s2 second item to compare

Definition at line 2093 of file messages.c.

References message_summary::date.

int summcmp_rdate ( const void *  s1,
const void *  s2 
)

qsort() compatible function to compare two message summary structs by descending date.

Parameters:
s1 first item to compare
s2 second item to compare

Definition at line 2111 of file messages.c.

References message_summary::date.

void readloop ( char *  oper  ) 

command loop for reading messages

Parameters:
oper Set to "readnew" or "readold" or "readfwd" or "headers"

mailbox sort

message board sort

When in summary mode, always show ALL messages instead of just new or old. Otherwise, show what the user asked for.

< fetch header summary

Are we doing a summary view? If so, we need to know old messages and new messages, so we can do that pretty boldface thing for the new messages.

< calendar

< tasks

< notes

Are you a new message, or an old message?

note that Date and Delete are now in the same column

Display the message

Set the "is_bbview" variable if it appears that we are looking at a classic bulletin board view.

Output loop

if we do a split bbview in the future, begin messages div here

if we do a split bbview in the future, end messages div here

< end of 'fix_scrollbar_bug' div

< end of 'message_list' div

Here's the grab-it-to-resize-the-message-list widget

< The preview pane will initially be empty

Bump these because although we're thinking in zero base, the user is a drooling idiot and is thinking in one base.

If we're not currently looking at ALL requested messages, then display the selector bar

begin bbview scroller

forward/reverse

end bbview scroller

Render the task list

Render the calendar

Render the address book

Note: wDumpContent() will output one additional tag.

free the summary

end of 'content' div

Definition at line 2130 of file messages.c.

References bstr(), get_preference(), http_redirect(), is_msg_in_mset(), load_msg_ptrs(), output_headers(), serv_getln(), serv_puts(), set_preference(), snprintf(), and wprintf().

Referenced by delete_msg(), display_enter(), move_msg(), post_message(), save_individual_event(), save_individual_task(), session_loop(), smart_goto(), and submit_vcard().

void post_mime_to_server ( void   ) 

Back end for post_message() ... this is where the actual message gets transmitted to the server.

RFC2045 requires this, and some clients look for it...

If there are attachments, we have to do multipart/mixed

Remember, serv_printf() appends an extra newline

Transmit message in quoted-printable encoding

Add in the attachments

Definition at line 2623 of file messages.c.

References bstr(), wc_attachment::content_type, CtdlEncodeBase64(), wc_attachment::data, wc_attachment::filename, wc_attachment::length, wc_attachment::next, serv_printf(), serv_puts(), serv_write(), and text_to_server_qp().

Referenced by post_message().

void post_message ( void   ) 

Post message (or don't post message).

Note regarding the "dont_post" variable: A random value (actually, it's just a timestamp) is inserted as a hidden field called "postseq" when the display_enter page is generated. This value is checked when posting, using the static variable dont_post. If a user attempts to post twice using the same dont_post value, the message is discarded. This prevents the accidental double-saving of the same message if the user happens to click the browser "back" button.

There's an attachment. Save it to this struct...

And add it to the list.

Mozilla sends a simple filename, which is what we want, but Satan's Browser sends an entire pathname. Reduce the path to just a filename if we need to.

Transfer control of this memory from the upload struct to the attachment struct.

We may have been supplied with instructions regarding the location to which we must return after posting. If found, go there.

If we were editing a page in a wiki room, go to that page now.

Otherwise, just go to the "read messages" loop.

Definition at line 2700 of file messages.c.

References bstr(), wc_attachment::content_type, wc_attachment::data, display_enter(), wc_attachment::filename, free_attachments(), http_redirect(), wc_attachment::length, lprintf(), wc_attachment::next, num_tokens(), post_mime_to_server(), readloop(), remove_token(), rfc2047encode(), serv_getln(), serv_puts(), and snprintf().

Referenced by session_loop().

void display_enter ( void   ) 

display the message entry screen

First test to see whether this is a room that requires recipients to be entered

570 means that we need a recipient here

Any other error means that we cannot continue

Are we perhaps in an address book view? If so, then an "enter message" command really means "add new entry."

Are we perhaps in a calendar room? If so, then an "enter message" command really means "add new calendar item."

Are we perhaps in a tasks view? If so, then an "enter message" command really means "add new task."

Otherwise proceed normally. Do a custom room banner with no navbar...

Now check our actual recipients if there are any

570 means we have an invalid recipient listed

Any other error means that we cannot continue

If we got this far, we can display the message entry screen.

begin message entry screen

header bar

header bar

header bar

Initialize the autocomplete ajax helpers (found in wclib.js)

Pop open an address book -- begin

Pop open an address book -- end

If we're continuing from a previous edit, put our partially-composed message back...

If we're replying quoted, insert the quote here...

If we're editing a wiki page, insert the existing page here...

Insert our signature if appropriate...

The following template embeds the TinyMCE richedit control, and automatically transforms the textarea into a richedit textarea.

Enumerate any attachments which are already in place...

Now offer the ability to attach additional files...

Make sure we only insert our signature once

Definition at line 2833 of file messages.c.

References bstr(), display_edit_event(), display_edit_task(), do_edit_vcard(), do_template(), embed_room_banner(), escputs(), wc_attachment::filename, fmt_date(), get_preference(), gotoroom(), msgescputs(), wc_attachment::next, output_headers(), pullquote_message(), readloop(), safestrncpy(), serv_getln(), serv_puts(), str_wiki_index(), urlescputs(), wDumpContent(), and wprintf().

Referenced by post_message(), and session_loop().

void delete_msg ( void   ) 

delete a message

Delete from Trash is a real delete

Otherwise move it to Trash

Definition at line 3192 of file messages.c.

References bstr(), readloop(), serv_getln(), and serv_printf().

Referenced by session_loop().


Generated on Wed Jun 20 23:13:13 2007 for webcit by  doxygen 1.5.2