X-Git-Url: http://git.marmaro.de/?a=blobdiff_plain;f=sbr%2Ffolder_addmsg.c;h=1af116cb71fe580316ceb4543d060998c3ba0cfa;hb=ac33b2e9c3632537b93fc4755a925c682d1eb82e;hp=6858f4db8d430ad4ad146cbec64d831a28332162;hpb=1691e80890e5d8ba258c51c214a3e91880e1db2b;p=mmh diff --git a/sbr/folder_addmsg.c b/sbr/folder_addmsg.c index 6858f4d..1af116c 100644 --- a/sbr/folder_addmsg.c +++ b/sbr/folder_addmsg.c @@ -3,6 +3,10 @@ * folder_addmsg.c -- Link message into folder * * $Id$ + * + * This code is Copyright (c) 2002, by the authors of nmh. See the + * COPYRIGHT file in the root directory of the nmh distribution for + * complete copyright information. */ #include @@ -16,10 +20,11 @@ int folder_addmsg (struct msgs **mpp, char *msgfile, int selected, - int unseen, int preserve) + int unseen, int preserve, int deleting, char *from_dir) { int infd, outfd, linkerr, first_time, msgnum; char *nmsg, newmsg[BUFSIZ]; + char oldmsg[BUFSIZ]; struct msgs *mp; struct stat st1, st2; @@ -128,9 +133,21 @@ folder_addmsg (struct msgs **mpp, char *msgfile, int selected, snprintf (newmsg, sizeof(newmsg), "%s/%s", mp->foldpath, nmsg); /* - * Now try to link message into folder + * Now try to link message into folder. + * Then run the external hook on the message if one was specified in the context. + * Run the refile hook if we're moving the message from one place to another. + * We have to construct the from path name for this because it's not there. + * Run the add hook if the message is getting copied or linked somewhere else. */ if (link (msgfile, newmsg) != -1) { + + if (deleting) { + (void)snprintf(oldmsg, sizeof (oldmsg), "%s/%s", from_dir, msgfile); + (void)ext_hook("ref-hook", oldmsg, newmsg); + } + else + (void)ext_hook("add-hook", newmsg, (char *)0); + return msgnum; } else { linkerr = errno; @@ -179,6 +196,14 @@ folder_addmsg (struct msgs **mpp, char *msgfile, int selected, cpydata (infd, outfd, msgfile, newmsg); close (infd); close (outfd); + + if (deleting) { + (void)snprintf(oldmsg, sizeof (oldmsg), "%s/%s", from_dir, msgfile); + (void)ext_hook("ref-hook", oldmsg, newmsg); + } + else + (void)ext_hook("add-hook", newmsg, (char *)0); + return msgnum; } }