]> git.pld-linux.org Git - packages/mutt.git/blame - mutt-xface.patch
- updated to 1.11.3
[packages/mutt.git] / mutt-xface.patch
CommitLineData
68eeb855 1x-face patch for Mutt 1.5.6
2
3Copied from Debian's slrnface package:
4
5 http://dave.willfork.com/slrnface/
6 Upstream Author: Drazen Kacar <dave@arsdigita.com>
7 Copyright: /usr/share/common-licenses/GPL
8
9
4c5b43c2 10--- mutt-1.4./README.xface Thu Jan 1 01:00:00 1970
11+++ mutt-1.4/README.xface Sat Aug 24 02:29:23 2002
12@@ -0,0 +1,80 @@
13+This is slrnface, a small helper utility which displays X-Faces on behalf
14+of programs like slrn and mutt when they are run in the X11 terminal
15+emulator.
16+
17+Requirements:
18+
19+a) X11.
20+b) Terminal emulator which sets WINDOWID environment variable. Most of the
21+ ones in common use will set it. If you're using some terminal emulator
22+ which doesn't have this capability, you'll have to set it yourself.
23+
24+How to build:
25+
26+a) Install libcompface. I recommend getting the source from the nearest
27+ Debian GNU/Linux mirror because there's a patch which adds the
28+ ability to output XBM image, as well as the historic brain dead
29+ format. Slrnface doesn't use that feature, but it might be handy for
30+ something else.
31+
32+b) Edit Makefile.
33+
34+c) Invoke make.
35+
36+d) Install with "make install".
37+
38+Upgrading from version 1.x:
39+
40+ If you have used one of the older versions of slrnface, you probably
41+ have .slrnface file in your home directory. You can delete it, because
42+ the new version doesn't use it any more. Instead, the pipes will be
43+ created in $HOME/.slrnfaces directory. There are no other user visible
44+ changes.
45+
46+Using slrnface with slrn:
47+
48+ This version requires S-Lang 1.4 or later and slrn 0.9.7.4. It might
49+ work with slrn 0.9.7.3, but I haven't tested that configuration. It
50+ will not work properly with older versions.
51+
52+ In case you can't or won't upgrade, take a look at the slrnface home
53+ page. You'll find older versions which might work with what you have.
54+
55+ Take a look at slrnface.sl, edit if you want and then include it in
56+ your .slrnrc, like this:
57+
58+ interpret slrnface.sl
59+
60+ Run slrn.
61+
62+Using slrnface with mutt:
63+
64+ Mutt doesn't have a way to use some kind of embeded interpreter, like
65+ S-Lang. Since Mutt's current capabilities are not good enough for our
66+ purposes, a patch for the source is provided. It has been tested with
67+ mutt 1.4, but it should work with the 1.3.x series, if x is high
68+ enough.
69+
70+ Uncompress mutt 1.4 source and apply mutt.patch from the slrnface
71+ distribution.
72+
73+ Compile mutt as usual.
74+
75+ Edit your ~/.muttrc and add:
76+
77+ set xface=yes
78+
79+ Run mutt.
80+
81+If you think X-Faces are not placed at the appropriate location on your
82+terminal emulator window or you don't like the colors, set some X resources.
83+Read the man page for more information. Additional documentation is in the
84+doc directory.
85+
86+Licence: GPL. See file called COPYING.
87+
88+Special thanks to Mark R. Bowyer for proofreading the man page.
89+
90+Home page: http://dave.willfork.com/slrnface/
91+
92+dave@willfork.com
68eeb855 93diff -urp ../MUTT/mutt/PATCHES mutt/PATCHES
94--- ../MUTT/mutt/PATCHES 2002-12-09 18:44:54.000000000 +0100
95+++ mutt/PATCHES 2004-07-21 16:02:16.000000000 +0200
96@@ -0,0 +1 @@
97+patch-1.5.6.cb.xface.1
98diff -urp ../MUTT/mutt/globals.h mutt/globals.h
99--- ../MUTT/mutt/globals.h.orig 2007-03-26 14:49:03.226880430 +0200
100+++ mutt/globals.h 2007-03-26 14:51:13.227945753 +0200
101@@ -218,6 +218,8 @@
4c5b43c2 102 WHERE ALIAS *Aliases INITVAL (0);
103 WHERE LIST *UserHeader INITVAL (0);
104
105+WHERE int slrnface_fd INITVAL (-1);
106+
68eeb855 107 /*-- formerly in pgp.h --*/
108 WHERE REGEXP PgpGoodSign;
109 WHERE char *PgpSignAs;
110diff -urp ../MUTT/mutt/init.c mutt/init.c
111--- ../MUTT/mutt/init.c 2004-07-18 01:25:28.000000000 +0200
112+++ mutt/init.c 2004-07-21 13:33:47.000000000 +0200
113@@ -43,6 +43,8 @@
4c5b43c2 114 #include <string.h>
115 #include <sys/utsname.h>
116 #include <errno.h>
117+#include <sys/types.h>
118+#include <fcntl.h>
119 #include <sys/wait.h>
120
121 void toggle_quadoption (int opt)
b324a978
AG
122@@ -2356,3 +2358,130 @@ int mutt_get_hook_type (const char *name
123 return 1;
4c5b43c2 124 }
b324a978 125
4c5b43c2 126+void mutt_start_slrnface(void)
127+{
128+ char *fifo;
129+ int pathlen, status;
130+ pid_t pid, pidst;
131+ struct utsname u;
132+
133+ if (!option(OPTXFACE))
134+ return;
135+
136+ /*
137+ * If we don't have display, there's no point. The user probably knows,
138+ * so fail silently.
139+ */
140+ if (!getenv("DISPLAY"))
141+ return;
142+ /* If there is no WINDOWID, complain. */
143+ if (!getenv ("WINDOWID"))
144+ {
145+ mutt_error (_("Cannot run slrnface: WINDOWID not found in environment."));
146+ return;
147+ }
148+
149+ uname (&u);
150+ pathlen = strlen (Homedir) + sizeof("/.slrnfaces/")
151+ + strlen (u.nodename) + 30;
152+ fifo = safe_malloc (pathlen);
153+ sprintf (fifo, "%s/.slrnfaces", Homedir);
154+ if (mkdir (fifo, 0700))
155+ {
156+ if (errno != EEXIST)
157+ {
158+ mutt_error (_("Cannot run slrnface: failed to create %s: %s."),
159+ fifo, strerror(errno));
160+ return;
161+ }
162+ }
163+ else
164+ {
165+ FILE *fp;
166+
167+ /* We'll abuse fifo filename memory here. It's long enough. */
168+ sprintf (fifo, "%s/.slrnfaces/README", Homedir);
169+ if ((fp = fopen (fifo, "w")) != NULL)
170+ {
171+ fputs (_(
172+"This directory is used to create named pipes for communication between\n"
173+"slrnface and its parent process. It should normally be empty because\n"
174+"the pipe is deleted right after it has been opened by both processes.\n\n"
175+"File names generated by slrnface have the form \"hostname.pid\". It is\n"
176+"probably an error if they linger here longer than a fraction of a second.\n\n"
177+"However, if the directory is mounted from an NFS server, you might see\n"
178+"special files created by your NFS server while slrnface is running.\n"
179+"Do not try to remove them.\n"), fp);
180+ fclose (fp);
181+ }
182+ }
183+
184+ status = snprintf (fifo, pathlen, "%s/.slrnfaces/%s.%ld", Homedir,
185+ u.nodename, (long)getpid());
186+ if (status < 0)
187+ goto clean_face;
188+
189+ unlink (fifo);
190+ if (mkfifo (fifo, 0600) < 0)
191+ {
192+ mutt_error (_("Cannot run slrnface, failed to create %s: %s."), fifo,
193+ strerror(errno));
194+ goto clean_face;
195+ }
196+
197+ pid = fork();
198+ switch (pid)
199+ {
200+ case -1: break;
201+ case 0: execlp ("slrnface", "slrnface", fifo, (char *)0);
202+ /* This is child, exit on error. */
203+ _exit (10);
204+ default: do {
205+ pidst = waitpid (pid, &status, 0);
206+ } while (pidst == -1 && errno == EINTR);
207+
208+ if (!WIFEXITED (status))
209+ mutt_error (_("Slrnface abnormaly exited, code %d."), status);
210+ else
211+ {
212+ char *message;
213+
214+ switch (WEXITSTATUS (status))
215+ {
216+ case 0: /* All fine, open the pipe */
217+ slrnface_fd = open (fifo, O_WRONLY, 0600);
218+ write (slrnface_fd, "start\n", sizeof "start");
219+ goto clean_face;
220+ case 1: message = "couldn't connect to display";
221+ break;
222+ case 2: message = "WINDOWID not found in environment";
223+ break;
224+ case 3: message = "couldn't find controlling terminal";
225+ break;
226+ case 4: message = "terminal doesn't export width and height";
227+ break;
228+ case 5: message = "cannot open FIFO";
229+ break;
230+ case 6: message = "fork() failed";
231+ break;
232+ case 10: message = "executable not found";
233+ break;
234+ default: message = "unknown error";
235+ }
236+ mutt_error (_("Slrnface failed: %s."), message);
237+ }
238+ }
239+
240+clean_face:
241+ unlink (fifo);
242+ free (fifo);
243+}
244+
245+void mutt_stop_slrnface(void)
246+{
247+ if (slrnface_fd >= 0)
248+ close(slrnface_fd);
249+ slrnface_fd = -1;
250+
251+ /* FIFO has been unlinked in the startup function. */
252+}
68eeb855 253diff -urp ../MUTT/mutt/init.h mutt/init.h
254--- ../MUTT/mutt/init.h 2004-07-21 13:33:02.000000000 +0200
255+++ mutt/init.h 2004-07-21 13:33:47.000000000 +0200
256@@ -2736,6 +2736,12 @@ struct option_t MuttVars[] = {
4c5b43c2 257 ** Controls whether mutt writes out the Bcc header when preparing
258 ** messages to be sent. Exim users may wish to use this.
259 */
260+ { "xface", DT_BOOL, R_NONE, OPTXFACE, 0 },
261+ /*
262+ ** .pp
263+ ** Controls whether mutt uses slrnface to display X-Faces when run
264+ ** in an X11 terminal emulator.
265+ */
266 /*--*/
267 { NULL }
268 };
68eeb855 269diff -urp ../MUTT/mutt/main.c mutt/main.c
270--- ../MUTT/mutt/main.c 2004-06-18 17:24:22.000000000 +0200
271+++ mutt/main.c 2004-07-21 13:33:47.000000000 +0200
272@@ -905,6 +905,8 @@ int main (int argc, char **argv)
4c5b43c2 273
274 mutt_folder_hook (folder);
275
276+ mutt_start_slrnface();
277+
b324a978 278 if((Context = mx_open_mailbox (folder, ((flags & MUTT_RO) || option (OPTREADONLY)) ? MUTT_READONLY : 0, NULL))
4c5b43c2 279 || !explicit_folder)
280 {
68eeb855 281@@ -913,6 +915,8 @@ int main (int argc, char **argv)
4c5b43c2 282 }
b324a978
AG
283
284 exit_endwin_msg = Errorbuf;
4c5b43c2 285+
286+ mutt_stop_slrnface();
287 }
288
b324a978 289 exit_code = 0;
68eeb855 290diff -urp ../MUTT/mutt/mutt.h mutt/mutt.h
291--- ../MUTT/mutt/mutt.h 2004-07-21 13:33:02.000000000 +0200
292+++ mutt/mutt.h 2004-07-21 13:33:47.000000000 +0200
293@@ -435,6 +435,7 @@ enum
4c5b43c2 294 OPTWRAP,
295 OPTWRAPSEARCH,
296 OPTWRITEBCC, /* write out a bcc header? */
297+ OPTXFACE,
298 OPTXMAILER,
299
68eeb855 300 OPTCRYPTUSEGPGME,
301@@ -577,6 +578,7 @@ typedef struct envelope
302 BUFFER *spam;
4c5b43c2 303 LIST *references; /* message references (in reverse order) */
304 LIST *in_reply_to; /* in-reply-to header content */
305+ LIST *x_face; /* X-Face header content */
306 LIST *userhdrs; /* user defined headers */
307 } ENVELOPE;
308
68eeb855 309diff -urp ../MUTT/mutt/muttlib.c mutt/muttlib.c
310--- ../MUTT/mutt/muttlib.c 2004-07-18 01:25:28.000000000 +0200
311+++ mutt/muttlib.c 2004-07-21 13:33:47.000000000 +0200
312@@ -651,6 +651,7 @@ void mutt_free_envelope (ENVELOPE **p)
313 FREE (&(*p)->date);
4c5b43c2 314 mutt_free_list (&(*p)->references);
315 mutt_free_list (&(*p)->in_reply_to);
316+ mutt_free_list (&(*p)->x_face);
317 mutt_free_list (&(*p)->userhdrs);
68eeb855 318 FREE (p);
4c5b43c2 319 }
68eeb855 320diff -urp ../MUTT/mutt/pager.c mutt/pager.c
321--- ../MUTT/mutt/pager.c 2004-07-18 01:25:28.000000000 +0200
322+++ mutt/pager.c 2004-07-21 13:36:34.000000000 +0200
c59ea3a3 323@@ -1527,6 +1527,66 @@ upNLines (int nlines, struct line_t *inf
4c5b43c2 324 return cur;
325 }
326
327+static void
328+mutt_display_xface (HEADER *hdr)
329+{
330+ LIST *face;
331+ char buf[2000];
332+
333+ if (slrnface_fd < 0)
334+ return;
335+
336+ if (!hdr)
337+ return;
338+
339+ face = hdr->env->x_face;
340+
341+ if (face == NULL || face->data == NULL)
342+ write(slrnface_fd, "clear\n", sizeof "clear");
343+ else
344+ do {
345+ int len;
346+
347+ len = snprintf (buf, sizeof (buf), "xface %s\n", face->data);
348+ if (len <= sizeof (buf))
349+ {
350+ write (slrnface_fd, buf, len);
351+ break;
352+ }
353+ /*
354+ * slrnface will ignore X-Faces larger than approx. 2000 chars, so
355+ * try the next one, if it exists.
356+ */
357+ } while (face = face->next);
358+}
359+
360+static void
361+mutt_clear_xface (void)
362+{
363+ if (slrnface_fd < 0)
364+ return;
365+
366+ write(slrnface_fd, "clear\n", sizeof "clear");
367+}
368+
369+static void
370+mutt_suppress_xface (void)
371+{
372+ if (slrnface_fd < 0)
373+ return;
374+
375+ write(slrnface_fd, "suppress\n", sizeof "suppress");
376+}
377+
378+static void
379+mutt_show_xface (void)
380+{
381+ if (slrnface_fd < 0)
382+ return;
383+
384+ write(slrnface_fd, "show\n", sizeof "show");
385+}
386+
c59ea3a3 387 static const struct mapping_t PagerHelp[] = {
4c5b43c2 388 { N_("Exit"), OP_EXIT },
389 { N_("PrevPg"), OP_PREV_PAGE },
68eeb855 390@@ -1545,6 +1605,9 @@ mutt_pager (const char *banner, const ch
4c5b43c2 391 snprintf (helpstr, sizeof (helpstr), "%s %s", tmphelp, buffer);
392 }
393
394+ if (IsHeader (extra))
395+ mutt_display_xface(extra->hdr);
396+
397 while (ch != -1)
398 {
399 mutt_curs_set (0);
68eeb855 400@@ -2067,7 +2130,9 @@ search_next:
4c5b43c2 401 if (! InHelp)
402 {
403 InHelp = 1;
404+ mutt_suppress_xface ();
405 mutt_help (MENU_PAGER);
406+ mutt_show_xface ();
b324a978 407 pager_menu->redraw = REDRAW_FULL;
4c5b43c2 408 InHelp = 0;
409 }
b324a978 410@@ -2383,58 +2448,70 @@ CHECK_IMAP_ACL(IMAP_ACL_WRITE);
4c5b43c2 411 case OP_MAIL:
412 CHECK_MODE(IsHeader (extra) && !IsAttach (extra));
413 CHECK_ATTACH;
414+ mutt_suppress_xface ();
68eeb855 415 ci_send_message (0, NULL, NULL, extra->ctx, NULL);
4c5b43c2 416+ mutt_show_xface ();
b324a978 417 pager_menu->redraw = REDRAW_FULL;
4c5b43c2 418 break;
419
420 case OP_REPLY:
421 CHECK_MODE(IsHeader (extra) || IsMsgAttach (extra));
422 CHECK_ATTACH;
423+ mutt_suppress_xface();
424 if (IsMsgAttach (extra))
b324a978
AG
425 mutt_attach_reply (extra->fp, extra->hdr, extra->actx,
426 extra->bdy, SENDREPLY);
4c5b43c2 427 else
428 ci_send_message (SENDREPLY, NULL, NULL, extra->ctx, extra->hdr);
429+ mutt_show_xface ();
b324a978 430 pager_menu->redraw = REDRAW_FULL;
4c5b43c2 431 break;
432
433 case OP_RECALL_MESSAGE:
68eeb855 434 CHECK_MODE(IsHeader (extra) && !IsAttach(extra));
4c5b43c2 435 CHECK_ATTACH;
436+ mutt_suppress_xface();
437 ci_send_message (SENDPOSTPONED, NULL, NULL, extra->ctx, extra->hdr);
438+ mutt_show_xface ();
b324a978 439 pager_menu->redraw = REDRAW_FULL;
4c5b43c2 440 break;
441
442 case OP_GROUP_REPLY:
443 CHECK_MODE(IsHeader (extra) || IsMsgAttach (extra));
444 CHECK_ATTACH;
445+ mutt_suppress_xface();
446 if (IsMsgAttach (extra))
b324a978
AG
447 mutt_attach_reply (extra->fp, extra->hdr, extra->actx,
448 extra->bdy, SENDREPLY|SENDGROUPREPLY);
4c5b43c2 449 else
450 ci_send_message (SENDREPLY | SENDGROUPREPLY, NULL, NULL, extra->ctx, extra->hdr);
451+ mutt_suppress_xface ();
b324a978 452 pager_menu->redraw = REDRAW_FULL;
4c5b43c2 453 break;
454
455 case OP_LIST_REPLY:
456 CHECK_MODE(IsHeader (extra) || IsMsgAttach (extra));
457 CHECK_ATTACH;
458+ mutt_suppress_xface();
459 if (IsMsgAttach (extra))
b324a978
AG
460 mutt_attach_reply (extra->fp, extra->hdr, extra->actx,
461 extra->bdy, SENDREPLY|SENDLISTREPLY);
4c5b43c2 462 else
463 ci_send_message (SENDREPLY | SENDLISTREPLY, NULL, NULL, extra->ctx, extra->hdr);
464+ mutt_show_xface ();
b324a978 465 pager_menu->redraw = REDRAW_FULL;
4c5b43c2 466 break;
467
468 case OP_FORWARD_MESSAGE:
469 CHECK_MODE(IsHeader (extra) || IsMsgAttach (extra));
470 CHECK_ATTACH;
471+ mutt_suppress_xface();
472 if (IsMsgAttach (extra))
b324a978
AG
473 mutt_attach_forward (extra->fp, extra->hdr, extra->actx,
474 extra->bdy);
4c5b43c2 475 else
476 ci_send_message (SENDFORWARD, NULL, NULL, extra->ctx, extra->hdr);
477+ mutt_show_xface ();
b324a978 478 pager_menu->redraw = REDRAW_FULL;
4c5b43c2 479 break;
480
68eeb855 481@@ -2485,7 +2562,9 @@ CHECK_IMAP_ACL(IMAP_ACL_WRITE);
4c5b43c2 482 break;
483
484 case OP_SHELL_ESCAPE:
485+ mutt_suppress_xface ();
486 mutt_shell_escape ();
487+ mutt_show_xface ();
4c5b43c2 488 break;
489
b324a978 490 case OP_TAG:
68eeb855 491@@ -2644,5 +2723,6 @@ CHECK_IMAP_ACL(IMAP_ACL_DELETE);
b324a978
AG
492 FREE (&rd.pager_status_window);
493 FREE (&rd.pager_window);
494
4c5b43c2 495+ mutt_clear_xface ();
496 return (rc != -1 ? rc : 0);
497 }
68eeb855 498diff -urp ../MUTT/mutt/parse.c mutt/parse.c
499--- ../MUTT/mutt/parse.c 2004-07-21 13:33:02.000000000 +0200
500+++ mutt/parse.c 2004-07-21 13:33:47.000000000 +0200
501@@ -85,6 +85,27 @@ static char *read_rfc822_line (FILE *f,
4c5b43c2 502 /* not reached */
503 }
504
505+static LIST *mutt_add_x_face (LIST *lst, char *face)
506+{
507+ LIST *n;
508+
509+ n = safe_malloc(sizeof(LIST));
510+ n->data = safe_strdup(face);
511+ n->next = NULL;
512+
513+ if (lst)
514+ {
515+ LIST *l;
516+
517+ for(l = lst; l->next; l = l->next);
518+ l->next = n;
519+ }
520+ else
521+ lst = n;
522+
523+ return lst;
524+}
525+
526 static LIST *mutt_parse_references (char *s, int in_reply_to)
527 {
528 LIST *t, *lst = NULL;
68eeb855 529@@ -1231,6 +1252,11 @@ int mutt_parse_rfc822_line (ENVELOPE *e,
4c5b43c2 530 e->x_label = safe_strdup(p);
531 matched = 1;
532 }
533+ else if (ascii_strcasecmp (line+1, "-face") == 0)
534+ {
535+ e->x_face = mutt_add_x_face (e->x_face, p);
536+ matched = 1;
537+ }
538
539 default:
540 break;
68eeb855 541diff -urp ../MUTT/mutt/sendlib.c mutt/sendlib.c
542--- ../MUTT/mutt/sendlib.c 2004-07-21 13:33:02.000000000 +0200
543+++ mutt/sendlib.c 2004-07-21 13:37:16.000000000 +0200
544@@ -1697,6 +1697,15 @@ int mutt_write_rfc822_header (FILE *fp,
545 }
4c5b43c2 546 }
68eeb855 547
4c5b43c2 548+ /* Add X-Face headers */
549+ if (env->x_face)
550+ {
551+ LIST *face;
552+
553+ for (face = env->x_face; face; face = face->next)
554+ fprintf (fp, "X-Face: %s\n", face->data);
555+ }
556+
68eeb855 557 if (mode == 0 && !privacy && option (OPTXMAILER) && !has_agent)
4c5b43c2 558 {
559 /* Add a vanity header */
This page took 0.142153 seconds and 4 git commands to generate.