From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 13445 invoked from network); 28 May 2021 22:26:06 -0000 Received: from 1ess.inri.net (216.126.196.35) by inbox.vuxu.org with ESMTPUTF8; 28 May 2021 22:26:06 -0000 Received: from mail-qk1-f176.google.com ([209.85.222.176]) by 1ess; Fri May 28 18:18:12 -0400 2021 Received: by mail-qk1-f176.google.com with SMTP id k4so5676475qkd.0 for <9front@9front.org>; Fri, 28 May 2021 15:18:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:to:subject:from:date:in-reply-to :mime-version:content-transfer-encoding; bh=+G4ZbWOXCGmRZt9IbnlnhZqyLiA2KrDV8rhBbnDoZCA=; b=syUDzOZYAmRFTHffFX7TeVI9lvepNhXtwCkmMffMeuRxT227LxanyKrR6watChXlhW LtDOxJoyZA3cwt3VeFJeQU6Z4JU7QjoSR+L31VRzST/DMnJ/ziqo9w4pQUR2X0u4AbDk jnPmePNAkduSRgKqe7JYque2FccJ4aSTkTY7tDnJV5MpYAr05wixWWGeSUbXDgpyJBSE RtmkkW1aGeXrSef2Y37xVhhwZ5dojj1PSZqn5QLV28lbkg6INWbTNwDMjWlzih2kSUSf A0IX9x9nQWogj6ezLUkIGqW+Z7ylsAQCl3Q4858Sk24ETKEBVhAnR5ZLvffAtkToh4pR Ci5A== X-Gm-Message-State: AOAM532QlLG93W/6QmbVGwLI6gaPV9hFRxQ7dtLyif/t432JVL7F/Zos R/E8SQFoJtcZU1mjrKz2D2+1Jc/ng4g= X-Google-Smtp-Source: ABdhPJxpDXvOaZL38XLDBlmlz4IBYfC83H+a60LSn74UMYlkXzTj4iWa5IISz9CXrSpHVSOCGDJdPQ== X-Received: by 2002:a05:622a:24a:: with SMTP id c10mr5552667qtx.86.1622239898308; Fri, 28 May 2021 15:11:38 -0700 (PDT) Return-Path: Received: from santiago.9project.net (9project.net. [66.42.81.205]) by smtp.gmail.com with ESMTPSA id z17sm4322610qkb.59.2021.05.28.15.11.37 for <9front@9front.org> (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 May 2021 15:11:37 -0700 (PDT) Message-ID: <4D7FA5D61E1F603FA532CC77D395BC31@gmail.com> To: 9front@9front.org From: kjn@9project.net Date: Fri, 28 May 2021 17:11:32 -0500 In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit List-ID: <9front.9front.org> List-Help: X-Glyph: ➈ X-Bullshit: secure realtime hardware method content-driven interface Subject: Re: [9front] upas/fs: copy messages between IMAP folders Reply-To: 9front@9front.org Precedence: bulk Quoth risto.salminen@gmx.com: > Dear 9front community, > > it is currently not possible to copy messages between > IMAP folders in any way using upas, if I understand > correctly. upas/fs does not support putting messages > to the mailbox directories in /mail/fs/. The need for > this arises when someone wants to archive messages > from inbox to another IMAP folder. > > The following patch attempts to implement the support > for copying messages between IMAP folders in a similar > way in which flagging and deleting messages are handled. > The same functionality could be extended to other mailbox > types too, although it seems that currently this is only > useful with IMAP. I have been using this for half a year > now without any problems. > > The alternative way to achieve the same result would > be to make upas/fs support writing files to the > /mail/fs/ folders. Then perhaps upas/mbappend could > be used to write messages to these folders in the same > way as it can currently be used to write messages to > the /mail/box/ folders. However, the message numbering > schemes are different between these two folder > hierarchies, so there would have to be some special > casing for that, which would complicate things. > Implementing the feature that way would seem to be > more challenging in other ways too, which is why I am > presenting a simpler approach. > > Would this be useful for the broader audience? > > Thanks, > rsal > > diff -r 7c895ae504fa sys/man/4/upasfs > --- a/sys/man/4/upasfs Fri May 28 13:02:58 2021 +0200 > +++ b/sys/man/4/upasfs Fri May 28 16:40:56 2021 +0300 > @@ -206,7 +206,7 @@ > .I fs > to open, close, rename, create or remove new mailboxes, > and also to > -delete or flag groups of messages atomically. > +delete, flag, or copy groups of messages atomically. > The messages that can be written to this file are: > .TP 2i > .PD 0 > @@ -260,6 +260,13 @@ > .TP > .B "flag \fImboxname flags number ...\fP > flag the given messages. > +.TP > +.B "copy \fImboxname number ... target\fP > +Copy the given messages from > +.IR mboxname > +to mailbox named > +.IR target. > +At the moment only supported with IMAP mailboxes. > .PD > .PP > The > diff -r 7c895ae504fa sys/src/cmd/upas/fs/dat.h > --- a/sys/src/cmd/upas/fs/dat.h Fri May 28 13:02:58 2021 +0200 > +++ b/sys/src/cmd/upas/fs/dat.h Fri May 28 16:40:56 2021 +0300 > @@ -174,6 +174,7 @@ > void (*decache)(Mailbox*, Message*); > int (*fetch)(Mailbox*, Message*, uvlong, ulong); > void (*delete)(Mailbox*, Message*); > + char *(*copy)(Mailbox*, Message*, char*); > char *(*ctl)(Mailbox*, int, char**); > char *(*remove)(Mailbox *, int); > char *(*rename)(Mailbox*, char*, int); > @@ -215,6 +216,7 @@ > void unnewmessage(Mailbox*, Message*, Message*); > char* delmessages(int, char**); > char *flagmessages(int, char**); > +char* copymessages(int, char**); > void digestmessage(Mailbox*, Message*); > > int wraptls(int, char*); > diff -r 7c895ae504fa sys/src/cmd/upas/fs/fs.c > --- a/sys/src/cmd/upas/fs/fs.c Fri May 28 13:02:58 2021 +0200 > +++ b/sys/src/cmd/upas/fs/fs.c Fri May 28 16:40:56 2021 +0300 > @@ -1242,6 +1242,11 @@ > return nil; > return flagmessages(argc - 1, argv + 1); > } > + if(strcmp(argv[0], "copy") == 0){ > + if(argc < 4) > + return nil; > + return copymessages(argc - 1, argv + 1); > + } > if(strcmp(argv[0], "remove") == 0){ > v0 = argv0; > flags = 0; > diff -r 7c895ae504fa sys/src/cmd/upas/fs/imap.c > --- a/sys/src/cmd/upas/fs/imap.c Fri May 28 13:02:58 2021 +0200 > +++ b/sys/src/cmd/upas/fs/imap.c Fri May 28 16:40:56 2021 +0300 > @@ -1025,6 +1025,22 @@ > } > > static char* > +imap4copy(Mailbox *mb, Message *m, char *dest) > +{ > + char *r; > + Imap *imap; > + > + imap = mb->aux; > + if((ulong)(m->imapuid>>32) == imap->validity){ > + imap4cmd(imap, "uid copy %lud %s", (ulong)m->imapuid, dest); > + r = imap4resp(imap); > + if(!isokay(r)) > + return r; > + } > + return 0; > +} > + > +static char* > imap4sync(Mailbox *mb) > { > char *err; > @@ -1183,6 +1199,7 @@ > mb->delete = imap4delete; > mb->rename = imap4rename; > mb->modflags = imap4modflags; > + mb->copy = imap4copy; > mb->addfrom = 1; > return nil; > } > diff -r 7c895ae504fa sys/src/cmd/upas/fs/mbox.c > --- a/sys/src/cmd/upas/fs/mbox.c Fri May 28 13:02:58 2021 +0200 > +++ b/sys/src/cmd/upas/fs/mbox.c Fri May 28 16:40:56 2021 +0300 > @@ -1137,6 +1137,31 @@ > return rerr; > } > > +char* > +copymessages(int argc, char **argv) > +{ > + char *err, *dest, *rerr; > + int i; > + Mailbox *mb; > + Message *m; > + > + rerr = 0; > + for(mb = mbl; mb != nil; mb = mb->next) > + if(strcmp(*argv, mb->name) == 0) > + break; > + if(mb == nil) > + return "no such mailbox"; > + if(mb->copy == nil) > + return "copy not supported"; > + dest = argv[argc - 1]; > + for(i = 1; i < argc - 1; i++) > + for(m = mb->root->part; m; m = m->next) > + if(strcmp(m->name, argv[i]) == 0) > + if(err = mb->copy(mb, m, dest)) > + rerr = err; > + return rerr; > +} > + > void > msgincref(Mailbox *mb, Message *m) > { > diff -r 7c895ae504fa sys/src/cmd/upas/fs/mdir.c > --- a/sys/src/cmd/upas/fs/mdir.c Fri May 28 13:02:58 2021 +0200 > +++ b/sys/src/cmd/upas/fs/mdir.c Fri May 28 16:40:56 2021 +0300 > @@ -294,5 +294,6 @@ > mb->idxread = idxr; > mb->idxwrite = idxw; > mb->ctl = mdirctl; > + mb->copy = nil; > return nil; > } > diff -r 7c895ae504fa sys/src/cmd/upas/fs/plan9.c > --- a/sys/src/cmd/upas/fs/plan9.c Fri May 28 13:02:58 2021 +0200 > +++ b/sys/src/cmd/upas/fs/plan9.c Fri May 28 16:40:56 2021 +0300 > @@ -411,5 +411,6 @@ > mb->remove = localremove; > mb->rename = localrename; > mb->decache = plan9decache; > + mb->copy = nil; > return nil; > } > diff -r 7c895ae504fa sys/src/cmd/upas/fs/pop3.c > --- a/sys/src/cmd/upas/fs/pop3.c Fri May 28 13:02:58 2021 +0200 > +++ b/sys/src/cmd/upas/fs/pop3.c Fri May 28 16:40:56 2021 +0300 > @@ -624,6 +624,7 @@ > mb->sync = pop3sync; > mb->close = pop3close; > mb->ctl = pop3ctl; > + mb->copy = nil; > mb->addfrom = 1; > return nil; > } I have not tried out the patch, but I definitely have a use for copying messages from one imap folder to another. That's one remaining critical feature that I miss with mail on 9front. -- Kyle