X-Git-Url: http://git.marmaro.de/?p=mmh;a=blobdiff_plain;f=sbr%2Ffolder_addmsg.c;h=b3bc8914b74678d9c64e8a5648dbfeef8ce2fe56;hp=16f4cc523219299b49ce63540c420cb0c00093d8;hb=a259594cc41e41bfbb90562d3977b8194d1446f5;hpb=982194e9f1c9e4718b4857b300fc3ab8b16c8f6b diff --git a/sbr/folder_addmsg.c b/sbr/folder_addmsg.c index 16f4cc5..b3bc891 100644 --- a/sbr/folder_addmsg.c +++ b/sbr/folder_addmsg.c @@ -20,10 +20,12 @@ int folder_addmsg (struct msgs **mpp, char *msgfile, int selected, - int unseen, int preserve) + int unseen, int preserve, int deleting) { int infd, outfd, linkerr, first_time, msgnum; char *nmsg, newmsg[BUFSIZ]; + char oldmsg[BUFSIZ]; + struct msgs *op; struct msgs *mp; struct stat st1, st2; @@ -132,9 +134,23 @@ 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 lined somewhere else. */ if (link (msgfile, newmsg) != -1) { + + if (deleting) { + op = folder_read(getfolder(1)); + (void)snprintf(oldmsg, sizeof (oldmsg), "%s/%s", op->foldpath, msgfile); + folder_free(op); + (void)ext_hook("ref-hook", oldmsg, newmsg); + } + else + (void)ext_hook("add-hook", newmsg, (char *)0); + return msgnum; } else { linkerr = errno; @@ -183,6 +199,12 @@ folder_addmsg (struct msgs **mpp, char *msgfile, int selected, cpydata (infd, outfd, msgfile, newmsg); close (infd); close (outfd); + + if (deleting) + (void)ext_hook("ref-hook", newmsg, msgfile); + else + (void)ext_hook("add-hook", newmsg, (char *)0); + return msgnum; } }