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.
14 Index: xface/globals.h
15 ===================================================================
16 --- xface.orig/globals.h 2007-02-15 20:28:46.961763520 +0100
17 +++ xface/globals.h 2007-02-15 20:28:56.069378952 +0100
18 @@ -146,6 +146,11 @@ WHERE const char *ReleaseDate;
22 +WHERE char *UncompFace;
23 +WHERE char *IconToPbm;
24 +WHERE char *W3mImgDisplay;
27 WHERE LIST *AutoViewList INITVAL(0);
28 WHERE LIST *AlternativeOrderList INITVAL(0);
29 WHERE LIST *AttachAllow INITVAL(0);
31 ===================================================================
32 --- xface.orig/hcache.c 2007-02-15 20:28:46.968762456 +0100
33 +++ xface/hcache.c 2007-02-15 20:28:56.069378952 +0100
34 @@ -401,6 +401,7 @@ dump_envelope(ENVELOPE * e, unsigned cha
35 d = dump_char(e->message_id, d, off);
36 d = dump_char(e->supersedes, d, off);
37 d = dump_char(e->date, d, off);
38 + d = dump_char(e->x_face, d, off);
39 d = dump_char(e->x_label, d, off);
41 d = dump_buffer(e->spam, d, off);
42 @@ -438,6 +439,7 @@ restore_envelope(ENVELOPE * e, const uns
43 restore_char(&e->message_id, d, off);
44 restore_char(&e->supersedes, d, off);
45 restore_char(&e->date, d, off);
46 + restore_char(&e->x_face, d, off);
47 restore_char(&e->x_label, d, off);
49 restore_buffer(&e->spam, d, off);
51 ===================================================================
52 --- xface.orig/init.h 2007-02-15 20:28:46.976761240 +0100
53 +++ xface/init.h 2007-02-15 20:29:15.382442920 +0100
54 @@ -2941,6 +2941,31 @@ struct option_t MuttVars[] = {
55 ** Controls whether mutt writes out the Bcc header when preparing
56 ** messages to be sent. Exim users may wish to unset this.
58 + { "xface", DT_BOOL, R_NONE, OPTXFACE, 0 },
61 + ** Controls whether mutt displays X-Faces.
63 + { "xface_icontopbm", DT_PATH, R_NONE, UL &IconToPbm, UL "icontopbm" },
66 + ** Specify the path to ``icontopbm'' program.
68 + { "xface_uncompface", DT_PATH, R_NONE, UL &UncompFace, UL "uncompface" },
71 + ** Specify the path to ``uncompface'' program.
73 + { "xface_w3mimgdisplay",DT_PATH, R_NONE, UL &W3mImgDisplay, UL "/usr/lib/w3m/w3mimgdisplay" },
76 + ** Specify the path to ``w3mimgdisplay'' program.
78 + { "xface_w3mimgdisplay_options",DT_STR, R_NONE, UL &W3mOpt, UL "-x 5 -y 5" },
81 + ** Specify options for ``w3mimgdisplay'' program.
87 ===================================================================
88 --- xface.orig/mutt.h 2007-02-15 20:28:46.983760176 +0100
89 +++ xface/mutt.h 2007-02-15 20:28:56.071378648 +0100
90 @@ -450,6 +450,7 @@ enum
93 OPTWRITEBCC, /* write out a bcc header? */
98 @@ -587,6 +588,7 @@ typedef struct envelope
102 + char *x_face; /* X-Face header content */
105 LIST *references; /* message references (in reverse order) */
106 Index: xface/muttlib.c
107 ===================================================================
108 --- xface.orig/muttlib.c 2007-02-15 20:28:46.991758960 +0100
109 +++ xface/muttlib.c 2007-02-15 20:28:56.072378496 +0100
110 @@ -670,6 +670,7 @@ void mutt_free_envelope (ENVELOPE **p)
111 FREE (&(*p)->message_id);
112 FREE (&(*p)->supersedes);
114 + FREE (&(*p)->x_face);
115 FREE (&(*p)->x_label);
117 mutt_buffer_free (&(*p)->spam);
119 ===================================================================
120 --- xface.orig/pager.c 2007-02-15 20:28:47.000757592 +0100
121 +++ xface/pager.c 2007-02-15 20:28:56.072378496 +0100
122 @@ -1479,6 +1479,89 @@ upNLines (int nlines, struct line_t *inf
127 +display_xface (HEADER *hdr)
129 + char facefile[_POSIX_PATH_MAX + 1];
130 + char command[LONG_STRING];
132 + FILE *fpin = NULL, *fpout = NULL;
135 + /* everything ready? */
136 + if (!UncompFace || !(*UncompFace) ||
137 + !IconToPbm || !(*IconToPbm) ||
138 + !W3mImgDisplay || !(*W3mImgDisplay) ||
139 + !hdr || !hdr->env || !hdr->env->x_face)
142 + /* test w3mimgdisplay */
143 + snprintf (command, sizeof (command), "%s -test >/dev/null", W3mImgDisplay);
144 + if (mutt_system (command) == -1)
147 + /* prepare facedata */
148 + facedata = hdr->env->x_face;
150 + /* convert facedata to imagedata
151 + * and store imagedata in facefile
153 + mutt_mktemp (facefile);
154 + if ((fpout = safe_fopen (facefile, "w")) == NULL)
156 + mutt_error (_("Could not create temporary file!"));
159 + snprintf (command, sizeof (command),
160 + "( echo '/* Width=48, Height=48 */'; %s ) | %s",
161 + UncompFace, IconToPbm);
162 + pid = mutt_create_filter_fd
163 + (command, &fpin, NULL, NULL, -1, fileno (fpout), -1);
166 + mutt_perror (_("face filter"));
167 + safe_fclose (&fpout);
168 + mutt_unlink (facefile);
171 + /* pass facedata to converters */
172 + fputs (facedata, fpin);
173 + if (safe_fclose (&fpin) != 0 && errno != EPIPE)
177 + mutt_wait_filter (pid);
178 + safe_fclose (&fpout);
180 + mutt_unlink (facefile);
184 + mutt_wait_filter (pid);
185 + safe_fclose (&fpout);
190 + snprintf (command, sizeof (command),
191 + "%s %s", W3mImgDisplay, NONULL (W3mOpt));
192 + pid = mutt_create_filter_fd
193 + (command, &fpin, NULL, NULL, -1, -1, -1);
196 + mutt_perror ("w3mdisp");
197 + mutt_unlink (facefile);
200 + /* pass facefile to w3mimgdisplay */
201 + fprintf (fpin, "2;3;\n0;1;0;0;48;48;0;0;48;48;%s\n4;\n3;\n", facefile);
202 + if (safe_fclose (&fpin) != 0 && errno != EPIPE)
203 + mutt_perror ("w3mdisp");
204 + mutt_wait_filter (pid);
205 + mutt_unlink (facefile);
209 static struct mapping_t PagerHelp[] = {
210 { N_("Exit"), OP_EXIT },
211 { N_("PrevPg"), OP_PREV_PAGE },
212 @@ -1514,6 +1597,7 @@ mutt_pager (const char *banner, const ch
213 int lines = 0, curline = 0, topline = 0, oldtopline = 0, err, first = 1;
215 int redraw = REDRAW_FULL;
218 LOFF_T last_pos = 0, last_offset = 0;
219 int old_smart_wrap, old_markers;
220 @@ -1593,6 +1677,8 @@ mutt_pager (const char *banner, const ch
222 if (redraw & REDRAW_FULL)
224 + xface = 1; /* display xface later */
226 SETCOLOR (MT_COLOR_NORMAL);
227 /* clear() doesn't optimize screen redraws */
229 @@ -1794,6 +1880,11 @@ mutt_pager (const char *banner, const ch
230 } else move (statusoffset, COLS-1);
234 + if (option (OPTXFACE) && xface && IsHeader (extra))
235 + display_xface (extra->hdr);
238 if (IsHeader (extra) && OldHdr == extra->hdr && TopLine != topline
239 && lineInfo[curline].offset < sb.st_size-1)
242 ===================================================================
243 --- xface.orig/parse.c 2007-02-15 20:28:47.007756528 +0100
244 +++ xface/parse.c 2007-02-15 20:28:56.073378344 +0100
245 @@ -43,6 +43,7 @@ char *mutt_read_rfc822_line (FILE *f, ch
253 @@ -53,6 +54,9 @@ char *mutt_read_rfc822_line (FILE *f, ch
257 + if (ascii_strcasecmp (buf, "x-face:") == 0)
260 buf += strlen (buf) - 1;
263 @@ -71,9 +75,12 @@ char *mutt_read_rfc822_line (FILE *f, ch
264 /* eat tabs and spaces from the beginning of the continuation line */
265 while ((ch = fgetc (f)) == ' ' || ch == '\t')
268 - *++buf = ' '; /* string is still terminated because we removed
269 - at least one whitespace char above */
273 + *++buf = ' '; /* string is still terminated because we removed
274 + at least one whitespace char above */
279 @@ -1244,6 +1251,11 @@ int mutt_parse_rfc822_line (ENVELOPE *e,
280 e->x_label = safe_strdup(p);
283 + else if (ascii_strcasecmp (line+1, "-face") == 0)
285 + e->x_face = safe_strdup (p);
291 Index: xface/sendlib.c
292 ===================================================================
293 --- xface.orig/sendlib.c 2007-02-15 20:28:47.017755008 +0100
294 +++ xface/sendlib.c 2007-02-15 20:28:56.074378192 +0100
295 @@ -1829,6 +1829,9 @@ int mutt_write_rfc822_header (FILE *fp,
300 + fprintf (fp, "X-Face: %s\n", env->x_face);
302 if (mode == 0 && !privacy && option (OPTXMAILER) && !has_agent)
304 /* Add a vanity header */
308 +patch-1.5.13.tamo.w3mface.2