X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/f9754b35f2f3b4c5cb0890f154181d2bab66c679..4829d096feb337a55e2b866adb19acab9617b071:/uip/show.c diff --git a/uip/show.c b/uip/show.c index 004a2921..7aedb5f6 100644 --- a/uip/show.c +++ b/uip/show.c @@ -6,6 +6,9 @@ */ #include "h/mh.h" +#include "h/managed_folders.h" +#include "h/folder.h" +#include "mhlsbr.h" #include "sbr/m_name.h" #include "sbr/m_getfld.h" #include "sbr/getarguments.h" @@ -96,9 +99,8 @@ main (int argc, char **argv) bool checkmime = true; bool mime = false; int isdf = 0, mode = SHOW, msgnum; - char *cp, *maildir, *file = NULL, *folder = NULL, *proc, *program; + char *cp, *file = NULL, *folder = NULL, *proc, *program; char buf[BUFSIZ], **argp, **arguments; - struct msgs *mp = NULL; struct msgs_array msgs = { 0, 0, NULL }; struct msgs_array vec = { 0, 0, NULL }, non_mhl_vec = { 0, 0, NULL }; @@ -253,42 +255,16 @@ usage: if (!folder) folder = getfolder (1); - maildir = m_maildir (folder); + mh_managed_folders *mmfs; + if (!mh_managed_folders_open(&mmfs)) + die("%s", mh_managed_folders_get_err_string(mmfs)); + mh_folder *mhf; + if (!mh_folder_open(&mhf, folder, mmfs)) + die("%s", mh_folder_get_err_string(mhf)); + const struct msgs *const mp = mh_folder_select_and_chdir_and_mark_seen(&vec, mhf, msgs); + if (mp == NULL) + die("%s", mh_folder_get_err_string(mhf)); - if (chdir (maildir) == NOTOK) - adios (maildir, "unable to change directory to"); - - /* read folder and create message structure */ - if (!(mp = folder_read (folder, 1))) - die("unable to read folder %s", folder); - - /* check for empty folder */ - if (mp->nummsg == 0) - die("no messages in %s", folder); - - /* parse all the message ranges/sequences and set SELECTED */ - for (msgnum = 0; msgnum < msgs.size; msgnum++) - if (!m_convert (mp, msgs.msgs[msgnum])) - done (1); - - /* - * Set the SELECT_UNSEEN bit for all the SELECTED messages, - * since we will use that as a tag to know which messages - * to remove from the "unseen" sequence. - */ - for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++) - if (is_selected(mp, msgnum)) - set_unseen (mp, msgnum); - - seq_setprev (mp); /* set the Previous-Sequence */ - seq_setunseen (mp, 1); /* unset the Unseen-Sequence */ - - for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++) - if (is_selected(mp, msgnum)) - app_msgarg(&vec, mh_xstrdup(m_name (msgnum))); - - seq_setcur (mp, mp->hghsel); /* update current message */ - seq_save (mp); /* synchronize sequences */ context_replace (pfolder, folder); /* update current folder */ context_save (); /* save the context file */