2 This is the xface (w3mface) patch by TAKAHASHI Tamotsu
3 <ttakah@lapis.plala.or.jp>.
5 Needs w3m-img, compface, and netpbm installed.
7 * Homepage: http://www.df7cb.de/projects/mutt/x-face/
10 - Remove LIBEXECDIR definition to avoid needing rerunning automake,
11 hardcode /usr/lib/w3m/w3mimgdisplay.
15 ===================================================================
16 --- xface/PATCHES.orig 2007-02-15 20:29:41.458478760 +0100
17 +++ xface/PATCHES 2007-02-15 20:29:41.458478760 +0100
19 +patch-1.5.13.tamo.w3mface.2
20 Index: xface/globals.h
21 ===================================================================
22 --- xface.orig/globals.h 2007-02-15 20:28:46.961763520 +0100
23 +++ xface/globals.h 2007-02-15 20:28:56.069378952 +0100
24 @@ -146,6 +146,11 @@ WHERE const char *ReleaseDate;
28 +WHERE char *UncompFace;
29 +WHERE char *IconToPbm;
30 +WHERE char *W3mImgDisplay;
33 WHERE LIST *AutoViewList INITVAL(0);
34 WHERE LIST *AlternativeOrderList INITVAL(0);
35 WHERE LIST *AttachAllow INITVAL(0);
37 ===================================================================
38 --- xface.orig/hcache.c 2007-02-15 20:28:46.968762456 +0100
39 +++ xface/hcache.c 2007-02-15 20:28:56.069378952 +0100
40 @@ -401,6 +401,7 @@ dump_envelope(ENVELOPE * e, unsigned cha
41 d = dump_char(e->message_id, d, off);
42 d = dump_char(e->supersedes, d, off);
43 d = dump_char(e->date, d, off);
44 + d = dump_char(e->x_face, d, off);
45 d = dump_char(e->x_label, d, off);
47 d = dump_buffer(e->spam, d, off);
48 @@ -438,6 +439,7 @@ restore_envelope(ENVELOPE * e, const uns
49 restore_char(&e->message_id, d, off);
50 restore_char(&e->supersedes, d, off);
51 restore_char(&e->date, d, off);
52 + restore_char(&e->x_face, d, off);
53 restore_char(&e->x_label, d, off);
55 restore_buffer(&e->spam, d, off);
57 ===================================================================
58 --- xface.orig/init.h 2007-02-15 20:28:46.976761240 +0100
59 +++ xface/init.h 2007-02-15 20:29:15.382442920 +0100
60 @@ -2941,6 +2941,31 @@ struct option_t MuttVars[] = {
61 ** Controls whether mutt writes out the Bcc header when preparing
62 ** messages to be sent. Exim users may wish to unset this.
64 + { "xface", DT_BOOL, R_NONE, OPTXFACE, 0 },
67 + ** Controls whether mutt displays X-Faces.
69 + { "xface_icontopbm", DT_PATH, R_NONE, UL &IconToPbm, UL "icontopbm" },
72 + ** Specify the path to ``icontopbm'' program.
74 + { "xface_uncompface", DT_PATH, R_NONE, UL &UncompFace, UL "uncompface" },
77 + ** Specify the path to ``uncompface'' program.
79 + { "xface_w3mimgdisplay",DT_PATH, R_NONE, UL &W3mImgDisplay, UL "/usr/lib/w3m/w3mimgdisplay" },
82 + ** Specify the path to ``w3mimgdisplay'' program.
84 + { "xface_w3mimgdisplay_options",DT_STR, R_NONE, UL &W3mOpt, UL "-x 5 -y 5" },
87 + ** Specify options for ``w3mimgdisplay'' program.
93 ===================================================================
94 --- xface.orig/mutt.h 2007-02-15 20:28:46.983760176 +0100
95 +++ xface/mutt.h 2007-02-15 20:28:56.071378648 +0100
96 @@ -450,6 +450,7 @@ enum
99 OPTWRITEBCC, /* write out a bcc header? */
104 @@ -587,6 +588,7 @@ typedef struct envelope
108 + char *x_face; /* X-Face header content */
111 LIST *references; /* message references (in reverse order) */
112 Index: xface/muttlib.c
113 ===================================================================
114 --- xface.orig/muttlib.c 2007-02-15 20:28:46.991758960 +0100
115 +++ xface/muttlib.c 2007-02-15 20:28:56.072378496 +0100
116 @@ -670,6 +670,7 @@ void mutt_free_envelope (ENVELOPE **p)
117 FREE (&(*p)->message_id);
118 FREE (&(*p)->supersedes);
120 + FREE (&(*p)->x_face);
121 FREE (&(*p)->x_label);
123 mutt_buffer_free (&(*p)->spam);
125 ===================================================================
126 --- xface.orig/pager.c 2007-02-15 20:28:47.000757592 +0100
127 +++ xface/pager.c 2007-02-15 20:28:56.072378496 +0100
128 @@ -1479,6 +1479,89 @@ upNLines (int nlines, struct line_t *inf
133 +display_xface (HEADER *hdr)
135 + char facefile[_POSIX_PATH_MAX + 1];
136 + char command[LONG_STRING];
138 + FILE *fpin = NULL, *fpout = NULL;
141 + /* everything ready? */
142 + if (!UncompFace || !(*UncompFace) ||
143 + !IconToPbm || !(*IconToPbm) ||
144 + !W3mImgDisplay || !(*W3mImgDisplay) ||
145 + !hdr || !hdr->env || !hdr->env->x_face)
148 + /* test w3mimgdisplay */
149 + snprintf (command, sizeof (command), "%s -test >/dev/null", W3mImgDisplay);
150 + if (mutt_system (command) == -1)
153 + /* prepare facedata */
154 + facedata = hdr->env->x_face;
156 + /* convert facedata to imagedata
157 + * and store imagedata in facefile
159 + mutt_mktemp (facefile);
160 + if ((fpout = safe_fopen (facefile, "w")) == NULL)
162 + mutt_error (_("Could not create temporary file!"));
165 + snprintf (command, sizeof (command),
166 + "( echo '/* Width=48, Height=48 */'; %s ) | %s",
167 + UncompFace, IconToPbm);
168 + pid = mutt_create_filter_fd
169 + (command, &fpin, NULL, NULL, -1, fileno (fpout), -1);
172 + mutt_perror (_("face filter"));
173 + safe_fclose (&fpout);
174 + mutt_unlink (facefile);
177 + /* pass facedata to converters */
178 + fputs (facedata, fpin);
179 + if (safe_fclose (&fpin) != 0 && errno != EPIPE)
183 + mutt_wait_filter (pid);
184 + safe_fclose (&fpout);
186 + mutt_unlink (facefile);
190 + mutt_wait_filter (pid);
191 + safe_fclose (&fpout);
196 + snprintf (command, sizeof (command),
197 + "%s %s", W3mImgDisplay, NONULL (W3mOpt));
198 + pid = mutt_create_filter_fd
199 + (command, &fpin, NULL, NULL, -1, -1, -1);
202 + mutt_perror ("w3mdisp");
203 + mutt_unlink (facefile);
206 + /* pass facefile to w3mimgdisplay */
207 + fprintf (fpin, "2;3;\n0;1;0;0;48;48;0;0;48;48;%s\n4;\n3;\n", facefile);
208 + if (safe_fclose (&fpin) != 0 && errno != EPIPE)
209 + mutt_perror ("w3mdisp");
210 + mutt_wait_filter (pid);
211 + mutt_unlink (facefile);
215 static struct mapping_t PagerHelp[] = {
216 { N_("Exit"), OP_EXIT },
217 { N_("PrevPg"), OP_PREV_PAGE },
218 @@ -1514,6 +1597,7 @@ mutt_pager (const char *banner, const ch
219 int lines = 0, curline = 0, topline = 0, oldtopline = 0, err, first = 1;
221 int redraw = REDRAW_FULL;
224 LOFF_T last_pos = 0, last_offset = 0;
225 int old_smart_wrap, old_markers;
226 @@ -1593,6 +1677,8 @@ mutt_pager (const char *banner, const ch
228 if (redraw & REDRAW_FULL)
230 + xface = 1; /* display xface later */
232 SETCOLOR (MT_COLOR_NORMAL);
233 /* clear() doesn't optimize screen redraws */
235 @@ -1794,6 +1880,11 @@ mutt_pager (const char *banner, const ch
236 } else move (statusoffset, COLS-1);
240 + if (option (OPTXFACE) && xface && IsHeader (extra))
241 + display_xface (extra->hdr);
244 if (IsHeader (extra) && OldHdr == extra->hdr && TopLine != topline
245 && lineInfo[curline].offset < sb.st_size-1)
248 ===================================================================
249 --- xface.orig/parse.c 2007-02-15 20:28:47.007756528 +0100
250 +++ xface/parse.c 2007-02-15 20:28:56.073378344 +0100
251 @@ -43,6 +43,7 @@ char *mutt_read_rfc822_line (FILE *f, ch
259 @@ -53,6 +54,9 @@ char *mutt_read_rfc822_line (FILE *f, ch
263 + if (ascii_strcasecmp (buf, "x-face:") == 0)
266 buf += strlen (buf) - 1;
269 @@ -71,9 +75,12 @@ char *mutt_read_rfc822_line (FILE *f, ch
270 /* eat tabs and spaces from the beginning of the continuation line */
271 while ((ch = fgetc (f)) == ' ' || ch == '\t')
274 - *++buf = ' '; /* string is still terminated because we removed
275 - at least one whitespace char above */
279 + *++buf = ' '; /* string is still terminated because we removed
280 + at least one whitespace char above */
285 @@ -1244,6 +1251,11 @@ int mutt_parse_rfc822_line (ENVELOPE *e,
286 e->x_label = safe_strdup(p);
289 + else if (ascii_strcasecmp (line+1, "-face") == 0)
291 + e->x_face = safe_strdup (p);
297 Index: xface/sendlib.c
298 ===================================================================
299 --- xface.orig/sendlib.c 2007-02-15 20:28:47.017755008 +0100
300 +++ xface/sendlib.c 2007-02-15 20:28:56.074378192 +0100
301 @@ -1829,6 +1829,9 @@ int mutt_write_rfc822_header (FILE *fp,
306 + fprintf (fp, "X-Face: %s\n", env->x_face);
308 if (mode == 0 && !privacy && option (OPTXMAILER) && !has_agent)
310 /* Add a vanity header */