[PATCH] implement Forwarded flag

2018-02-22 Thread Michael J Gruber
maildir supports a 'P' flag which denotes the fact that a message has
been 'passed' on (forwarded, bounced). notmuch syncs this to the
'passed' tag.

Per https://tools.ietf.org/html/rfc5788, IMAP has a user-defined flag
(keyword) '$Forwarded' that is supported by many servers and clients
these days. (Technically, one should check for '$Forwarded' in the
server response.)

Restructure mbsync's flag parser to accept keywords (flags starting with
'$') but still bail out on unknown system flags (flags starting with '\').
Support '$Forwarded' as a first keyword since it maps to maildir's 'P'
and needs to be sorted in between the system flags.

Signed-off-by: Michael J Gruber 
---
I haven't found a "contrib HOW-TO" but hope this is okay.

I've checked that this works against a fairly standard IMAP server. The
mbsync source code uses a hardcoded numbering of the flags/bits in
several places - I hope I didn't miss any. Also, I'm not sure whether
the change in numbering is a problem - but maildir flags need to be
specified in alphabetical order, so 'P' has to go before 'R' and,
therefore, shift the indices of 'R', 'S' and 'T'. I do hope that they
are not recorded by bit number on disc somewhere (but only by flag
character as per the maildir standard).

 src/drv_imap.c| 22 --
 src/drv_maildir.c |  2 +-
 src/drv_proxy.c   |  2 +-
 src/sync.c|  2 +-
 4 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/src/drv_imap.c b/src/drv_imap.c
index 56d71cb..6b724e0 100644
--- a/src/drv_imap.c
+++ b/src/drv_imap.c
@@ -244,11 +244,12 @@ static int imap_deref( imap_store_t *ctx );
 static void imap_invoke_bad_callback( imap_store_t *ctx );
 
 static const char *Flags[] = {
-   "Draft",
-   "Flagged",
-   "Answered",
-   "Seen",
-   "Deleted",
+   "\\Draft",  /* 'D' */
+   "\\Flagged",/* 'F' */
+   "$Forwarded",   /* 'P' */
+   "\\Answered",   /* 'R' */
+   "\\Seen",   /* 'S' */
+   "\\Deleted",/* 'T' */
 };
 
 static imap_cmd_t *
@@ -986,18 +987,20 @@ parse_fetch_rsp( imap_store_t *ctx, list_t *list, char *s 
ATTR_UNUSED )
if (is_list( tmp )) {
for (flags = tmp->child; flags; flags = 
flags->next) {
if (is_atom( flags )) {
-   if (flags->val[0] == 
'\\') { /* ignore user-defined flags for now */
-   if (!strcmp( 
"Recent", flags->val + 1)) {
+   if (flags->val[0] == 
'\\' || flags->val[0] == '$') {
+   if (!strcmp( 
"\\Recent", flags->val)) {
status 
|= M_RECENT;
goto 
flagok;
}
for (i = 0; i < 
as(Flags); i++)
-   if 
(!strcmp( Flags[i], flags->val + 1 )) {
+   if 
(!strcmp( Flags[i], flags->val)) {

mask |= 1 << i;

goto flagok;
}
-   if 
(flags->val[1] == 'X' && flags->val[2] == '-')
+   if 
(flags->val[0] == '\\' && flags->val[1] == 'X' && flags->val[2] == '-')
goto 
flagok; /* ignore system flag extensions */
+   if 
(flags->val[0] == '$')
+   goto 
flagok; /* ignore unknown user-defined flags (keywords) */
error( "IMAP 
warning: unknown system flag %s\n", flags->val );
}
   

[PATCH v2] implement Forwarded flag

2018-02-24 Thread Michael J Gruber
maildir supports a 'P' flag which denotes the fact that a message has
been 'passed' on (forwarded, bounced). notmuch syncs this to the
'passed' tag.

Per https://tools.ietf.org/html/rfc5788, IMAP has a user-defined flag
(keyword) '$Forwarded' that is supported by many servers and clients
these days. (Technically, one should check for '$Forwarded' in the
server response.)

Restructure mbsync's flag parser to accept keywords (flags starting with
'$') but still bail out on unknown system flags (flags starting with '\').
Support '$Forwarded' as a first keyword since it maps to maildir's 'P'
and needs to be sorted in between the system flags.

Signed-off-by: Michael J Gruber 
---
And sure enough, there was yet another flag bit definition in
src/driver.h... Found out the hard way. (This is the the only change in
v2 compared to v1.)

 src/driver.h  |  9 +
 src/drv_imap.c| 22 --
 src/drv_maildir.c |  2 +-
 src/drv_proxy.c   |  2 +-
 src/sync.c|  2 +-
 5 files changed, 20 insertions(+), 17 deletions(-)

diff --git a/src/driver.h b/src/driver.h
index 7dc047a..af56069 100644
--- a/src/driver.h
+++ b/src/driver.h
@@ -48,10 +48,11 @@ typedef struct store_conf {
 /* The order is according to alphabetical maildir flag sort */
 #define F_DRAFT (1<<0) /* Draft */
 #define F_FLAGGED(1<<1) /* Flagged */
-#define F_ANSWERED   (1<<2) /* Replied */
-#define F_SEEN   (1<<3) /* Seen */
-#define F_DELETED(1<<4) /* Trashed */
-#define NUM_FLAGS 5
+#define F_PASSED (1<<2) /* Passed */
+#define F_ANSWERED   (1<<3) /* Replied */
+#define F_SEEN   (1<<4) /* Seen */
+#define F_DELETED(1<<5) /* Trashed */
+#define NUM_FLAGS 6
 
 /* For message->status */
 #define M_RECENT   (1<<0) /* unsyncable flag; maildir_* depend on this 
being 1<<0 */
diff --git a/src/drv_imap.c b/src/drv_imap.c
index 56d71cb..6b724e0 100644
--- a/src/drv_imap.c
+++ b/src/drv_imap.c
@@ -244,11 +244,12 @@ static int imap_deref( imap_store_t *ctx );
 static void imap_invoke_bad_callback( imap_store_t *ctx );
 
 static const char *Flags[] = {
-   "Draft",
-   "Flagged",
-   "Answered",
-   "Seen",
-   "Deleted",
+   "\\Draft",  /* 'D' */
+   "\\Flagged",/* 'F' */
+   "$Forwarded",   /* 'P' */
+   "\\Answered",   /* 'R' */
+   "\\Seen",   /* 'S' */
+   "\\Deleted",/* 'T' */
 };
 
 static imap_cmd_t *
@@ -986,18 +987,20 @@ parse_fetch_rsp( imap_store_t *ctx, list_t *list, char *s 
ATTR_UNUSED )
if (is_list( tmp )) {
for (flags = tmp->child; flags; flags = 
flags->next) {
if (is_atom( flags )) {
-   if (flags->val[0] == 
'\\') { /* ignore user-defined flags for now */
-   if (!strcmp( 
"Recent", flags->val + 1)) {
+   if (flags->val[0] == 
'\\' || flags->val[0] == '$') {
+   if (!strcmp( 
"\\Recent", flags->val)) {
status 
|= M_RECENT;
goto 
flagok;
}
for (i = 0; i < 
as(Flags); i++)
-   if 
(!strcmp( Flags[i], flags->val + 1 )) {
+   if 
(!strcmp( Flags[i], flags->val)) {

mask |= 1 << i;

goto flagok;
}
-   if 
(flags->val[1] == 'X' && flags->val[2] == '-')
+   if 
(flags->val[0] == '\\' && flags->val[1] == 'X' && flags->val[2] == '-')
goto 
flagok; /* ignore system flag extensions */
+   if 
(flags->val[0

[PATCH v3 1/2] mark MAILBOX_DRIVER_FLAG locations in code

2018-06-23 Thread Michael J Gruber
Mailbox driver flags are defined in several flags. It is essential that
they are kept in sync, so mark them with the same string for easy
grepping with an alerting boiler plate.

Signed-off-by: Michael J Gruber 
---
 src/driver.h  | 3 ++-
 src/drv_imap.c| 3 +++
 src/drv_maildir.c | 3 +++
 src/drv_proxy.c   | 3 +++
 src/sync.c| 3 +++
 5 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/src/driver.h b/src/driver.h
index 7dc047a..978e144 100644
--- a/src/driver.h
+++ b/src/driver.h
@@ -44,7 +44,8 @@ typedef struct store_conf {
 } store_conf_t;
 
 /* For message->flags */
-/* Keep the mailbox driver flag definitions in sync! */
+/* Keep the mailbox driver flag definitions in sync: */
+/* grep for MAILBOX_DRIVER_FLAG */
 /* The order is according to alphabetical maildir flag sort */
 #define F_DRAFT (1<<0) /* Draft */
 #define F_FLAGGED(1<<1) /* Flagged */
diff --git a/src/drv_imap.c b/src/drv_imap.c
index 05afa09..fd46a0b 100644
--- a/src/drv_imap.c
+++ b/src/drv_imap.c
@@ -243,6 +243,9 @@ static int imap_deref( imap_store_t *ctx );
 
 static void imap_invoke_bad_callback( imap_store_t *ctx );
 
+/* Keep the mailbox driver flag definitions in sync: */
+/* grep for MAILBOX_DRIVER_FLAG */
+/* The order is according to alphabetical maildir flag sort */
 static const char *Flags[] = {
"Draft",
"Flagged",
diff --git a/src/drv_maildir.c b/src/drv_maildir.c
index 4a94696..31436f9 100644
--- a/src/drv_maildir.c
+++ b/src/drv_maildir.c
@@ -108,6 +108,9 @@ debug( const char *msg, ... )
va_end( va );
 }
 
+/* Keep the mailbox driver flag definitions in sync: */
+/* grep for MAILBOX_DRIVER_FLAG */
+/* The order is according to alphabetical maildir flag sort */
 static const char Flags[] = { 'D', 'F', 'R', 'S', 'T' };
 
 static uchar
diff --git a/src/drv_proxy.c b/src/drv_proxy.c
index 5010f60..43d7411 100644
--- a/src/drv_proxy.c
+++ b/src/drv_proxy.c
@@ -55,6 +55,9 @@ debugn( const char *msg, ... )
va_end( va );
 }
 
+/* Keep the mailbox driver flag definitions in sync: */
+/* grep for MAILBOX_DRIVER_FLAG */
+/* The order is according to alphabetical maildir flag sort */
 static const char Flags[] = { 'D', 'F', 'R', 'S', 'T' };
 
 static char *
diff --git a/src/sync.c b/src/sync.c
index 7397db2..d88344d 100644
--- a/src/sync.c
+++ b/src/sync.c
@@ -97,6 +97,9 @@ Fprintf( FILE *f, const char *msg, ... )
 }
 
 
+/* Keep the mailbox driver flag definitions in sync: */
+/* grep for MAILBOX_DRIVER_FLAG */
+/* The order is according to alphabetical maildir flag sort */
 static const char Flags[] = { 'D', 'F', 'R', 'S', 'T' };
 
 static int
-- 
2.18.0.rc1.265.g7dd663a68f


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
isync-devel mailing list
isync-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/isync-devel


Re: [PATCH v2] implement Forwarded flag

2018-06-23 Thread Michael J Gruber
Am So., 4. März 2018 um 13:20 Uhr schrieb Oswald Buddenhagen
:
>
> On Fri, Feb 23, 2018 at 04:26:17PM +0100, Michael J Gruber wrote:
> > maildir supports a 'P' flag which denotes the fact that a message has
> > been 'passed' on (forwarded, bounced). notmuch syncs this to the
> > 'passed' tag.
> >
> interesting.

Sorry for the long hiatus. I've been running that patch happily since
and forgot about the change requests:
>
> > And sure enough, there was yet another flag bit definition in
> > src/driver.h... Found out the hard way. (This is the the only change in
> > v2 compared to v1.)
> >
> it would make sense to add comments cross-referencing the instances in
> the same go.

I've put that into an introductory commit now, so that the
functionality change is isolated.

>
> > diff --git a/src/drv_imap.c b/src/drv_imap.c
> > @@ -986,18 +987,20 @@ parse_fetch_rsp( imap_store_t *ctx, list_t *list, 
> > char *s ATTR_UNUSED )
> > - if 
> > (flags->val[1] == 'X' && flags->val[2] == '-')
> > + if 
> > (flags->val[0] == '\\' && flags->val[1] == 'X' && flags->val[2] == '-')
> >   goto 
> > flagok; /* ignore system flag extensions */
> > + if 
> > (flags->val[0] == '$')
> > + goto 
> > flagok; /* ignore unknown user-defined flags (keywords) */
> >
> i'd move that above the previous case, to keep the system ones closer
> together.

I'm not sure which one is the previous (since `\\` is system and '$'
is user defined), but I'll swap the two in the upcoming patch. Both
should be after the for loop which catches known flags.

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
isync-devel mailing list
isync-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/isync-devel


[PATCH v3 2/2] implement Forwarded flag

2018-06-23 Thread Michael J Gruber
maildir supports a 'P' flag which denotes the fact that a message has
been 'passed' on (forwarded, bounced). notmuch syncs this to the
'passed' tag.

Per https://tools.ietf.org/html/rfc5788, IMAP has a user-defined flag
(keyword) '$Forwarded' that is supported by many servers and clients
these days. (Technically, one should check for '$Forwarded' in the
server response.)

Restructure mbsync's flag parser to accept keywords (flags starting with
'$') but still bail out on unknown system flags (flags starting with '\').
Support '$Forwarded' as a first keyword since it maps to maildir's 'P'
and needs to be sorted in between the system flags.

Signed-off-by: Michael J Gruber 
---
 src/driver.h  |  9 +
 src/drv_imap.c| 22 --
 src/drv_maildir.c |  2 +-
 src/drv_proxy.c   |  2 +-
 src/sync.c|  2 +-
 5 files changed, 20 insertions(+), 17 deletions(-)

diff --git a/src/driver.h b/src/driver.h
index 978e144..00c5581 100644
--- a/src/driver.h
+++ b/src/driver.h
@@ -49,10 +49,11 @@ typedef struct store_conf {
 /* The order is according to alphabetical maildir flag sort */
 #define F_DRAFT (1<<0) /* Draft */
 #define F_FLAGGED(1<<1) /* Flagged */
-#define F_ANSWERED   (1<<2) /* Replied */
-#define F_SEEN   (1<<3) /* Seen */
-#define F_DELETED(1<<4) /* Trashed */
-#define NUM_FLAGS 5
+#define F_PASSED (1<<2) /* Passed */
+#define F_ANSWERED   (1<<3) /* Replied */
+#define F_SEEN   (1<<4) /* Seen */
+#define F_DELETED(1<<5) /* Trashed */
+#define NUM_FLAGS 6
 
 /* For message->status */
 #define M_RECENT   (1<<0) /* unsyncable flag; maildir_* depend on this 
being 1<<0 */
diff --git a/src/drv_imap.c b/src/drv_imap.c
index fd46a0b..e782ec0 100644
--- a/src/drv_imap.c
+++ b/src/drv_imap.c
@@ -247,11 +247,12 @@ static void imap_invoke_bad_callback( imap_store_t *ctx );
 /* grep for MAILBOX_DRIVER_FLAG */
 /* The order is according to alphabetical maildir flag sort */
 static const char *Flags[] = {
-   "Draft",
-   "Flagged",
-   "Answered",
-   "Seen",
-   "Deleted",
+   "\\Draft",  /* 'D' */
+   "\\Flagged",/* 'F' */
+   "$Forwarded",   /* 'P' */
+   "\\Answered",   /* 'R' */
+   "\\Seen",   /* 'S' */
+   "\\Deleted",/* 'T' */
 };
 
 static imap_cmd_t *
@@ -989,17 +990,19 @@ parse_fetch_rsp( imap_store_t *ctx, list_t *list, char *s 
ATTR_UNUSED )
if (is_list( tmp )) {
for (flags = tmp->child; flags; flags = 
flags->next) {
if (is_atom( flags )) {
-   if (flags->val[0] == 
'\\') { /* ignore user-defined flags for now */
-   if (!strcmp( 
"Recent", flags->val + 1)) {
+   if (flags->val[0] == 
'\\' || flags->val[0] == '$') {
+   if (!strcmp( 
"\\Recent", flags->val)) {
status 
|= M_RECENT;
goto 
flagok;
}
for (i = 0; i < 
as(Flags); i++)
-   if 
(!strcmp( Flags[i], flags->val + 1 )) {
+   if 
(!strcmp( Flags[i], flags->val)) {

mask |= 1 << i;

goto flagok;
}
-   if 
(flags->val[1] == 'X' && flags->val[2] == '-')
+   if 
(flags->val[0] == '$')
+   goto 
flagok; /* ignore unknown user-defined flags (keywords) */
+   if 
(flags->val[0] == '\\' && flags->val[1] == 'X' && flags->val[2] == '-')

Re: isync GPL incompatibility due to Cyrus SASL

2022-07-05 Thread Michael J Gruber
Oswald Buddenhagen venit, vidit, dixit 2022-06-27 11:51 +0200:
> On Sun, Jun 26, 2022 at 02:07:01PM +0200, Oswald Buddenhagen wrote:
> > to address this issue, i intend to generalize the GPL exception as per
> > the attached patch.
> > 
> > > As a special exception, mbsync may be linked with libraries whose
> > > license contains advertising clauses.
> > 
> come to think of it, this is ambiguous and may be used to completely subvert
> the gpl. let's try this instead:
> 
> As a special exception, mbsync may be linked with libraries with a more
> restrictive license if the only incompatibility are advertising clauses.

I, Michael J Gruber, agree that my contributions to isync (minor as they
are) are covered by the new license as described above.

Cheers
Michael
> 
> 
> ___
> isync-devel mailing list
> isync-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/isync-devel


___
isync-devel mailing list
isync-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/isync-devel