*/
#include "util.h"
+#include "rfc822.h"
#include "charset.h"
#include <ctype.h>
debug("Charset is %s\n", system_charset);
}
-static void
-do_add_snippet(char **ppos, char *term, unsigned char *add)
+void
+add_snippet(char **ppos, char *term, char *add)
{
char *pos = *ppos;
int space = 1;
}
void
-add_snippet(char **ppos, char *term, char *add)
+add_subject_snippet(char **ppos, char *term, char *add)
{
char *buf = xstrdup(add);
rfc2047_decode(&buf);
- do_add_snippet(ppos, term, buf);
+ add_snippet(ppos, term, buf);
free(buf);
}
+
+void
+add_addr_snippet(char **ppos, char *term, char *add, int add_mbox, int add_personal)
+{
+ ADDRESS *addr = rfc822_parse_adrlist(NULL, add);
+ if (!addr)
+ {
+ debug("%s: Cannot parse address (%s)\n", add, rfc822_error(RFC822Error));
+ add_subject_snippet(ppos, term, add);
+ return;
+ }
+ // debug("%s: pers=%s mbox=%s\n", add, addr->personal, addr->mailbox);
+ rfc2047_decode(&addr->personal);
+ if (!addr->mailbox || !addr->mailbox[0])
+ add_mbox = 0;
+ if (!addr->personal || !addr->personal[0])
+ {
+ if (addr->mailbox && addr->mailbox[0])
+ {
+ char *c = strchr(addr->mailbox, '@');
+ if (c)
+ *c = 0;
+ add_mbox = 1;
+ }
+ add_personal = 0;
+ }
+ if (add_mbox || add_personal)
+ {
+ if (add_personal)
+ add_snippet(ppos, term, addr->personal);
+ if (add_mbox && add_personal)
+ add_snippet(ppos, term, " <");
+ if (add_mbox)
+ add_snippet(ppos, term, addr->mailbox);
+ if (add_mbox && add_personal)
+ add_snippet(ppos, term, ">");
+ }
+ else
+ add_snippet(ppos, term, "???");
+ rfc822_free_address(&addr);
+}
-/* Charset handling */
+/* Charset conversion and text snippets */
+void add_subject_snippet(char **ppos, char *term, char *add);
+void add_addr_snippet(char **ppos, char *term, char *add, int add_mbox, int add_personal);
void add_snippet(char **ppos, char *term, char *add);
void charset_init(void);
int beep;
int snippets;
int show_flagged;
+ int sender_personal;
+ int sender_mbox;
};
struct option_node {
};
static clist options, patterns;
-static struct options global_options;
+static struct options global_options = {
+ .sender_personal = 1
+};
struct mbox {
cnode n;
o->highlight = -1;
o->snippets = -1;
o->show_flagged = -1;
+ o->sender_personal = -1;
+ o->sender_mbox = -1;
}
static void
MERGE(beep);
MERGE(snippets);
MERGE(show_flagged);
+ MERGE(sender_personal);
+ MERGE(sender_mbox);
}
}
char *pos = b->snippet;
char *term = b->snippet + sizeof(b->snippet) - 1;
- if (sender[0])
+ if (sender[0] && (b->o.sender_mbox || b->o.sender_personal))
{
- add_snippet(&pos, term, sender);
+ add_addr_snippet(&pos, term, sender, b->o.sender_mbox, b->o.sender_personal);
add_snippet(&pos, term, ": ");
}
if (subject[0])
- add_snippet(&pos, term, subject);
+ add_subject_snippet(&pos, term, subject);
else
add_snippet(&pos, term, "No subject");
}
e\t\t\tHide from display if empty\n\
f\t\t\tShow flagged messages if there are no new ones\n\
h\t\t\tHide from display\n\
+m\t\t\tShow mailbox name of the sender\n\
+p\t\t\tShow personal info (full name) of the sender\n\
s\t\t\tShow message snippets\n\
t\t\t\tHighlight the entry\n\
\n\
case 'h':
o->hide = value;
break;
+ case 'm':
+ o->sender_mbox = value;
+ break;
+ case 'p':
+ o->sender_personal = value;
+ break;
case 's':
o->snippets = value;
break;