|
|
@ -196,7 +196,8 @@ parse_fetch (imap_t * imap, list_t * list, message_t *cur) |
|
|
|
else if (!strcmp ("\\Recent", flags->val)) |
|
|
|
else if (!strcmp ("\\Recent", flags->val)) |
|
|
|
cur->flags |= D_RECENT; |
|
|
|
cur->flags |= D_RECENT; |
|
|
|
else |
|
|
|
else |
|
|
|
printf ("Warning, unknown flag %s\n",flags->val); |
|
|
|
printf ("Warning, unknown flag %s\n", |
|
|
|
|
|
|
|
flags->val); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
puts ("Error, unable to parse FLAGS list"); |
|
|
|
puts ("Error, unable to parse FLAGS list"); |
|
|
@ -210,6 +211,32 @@ parse_fetch (imap_t * imap, list_t * list, message_t *cur) |
|
|
|
return 0; |
|
|
|
return 0; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void |
|
|
|
|
|
|
|
parse_response_code (imap_t * imap, char *s) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
char *arg; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (*s != '[') |
|
|
|
|
|
|
|
return; /* no response code */ |
|
|
|
|
|
|
|
s++; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
arg = next_arg (&s); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!strcmp ("UIDVALIDITY", arg)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
arg = next_arg (&s); |
|
|
|
|
|
|
|
imap->uidvalidity = atol (arg); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else if (!strcmp ("ALERT", arg)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
/* RFC2060 says that these messages MUST be displayed
|
|
|
|
|
|
|
|
* to the user |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
fputs ("***ALERT*** ", stdout); |
|
|
|
|
|
|
|
puts (s); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static int |
|
|
|
static int |
|
|
|
imap_exec (imap_t * imap, const char *fmt, ...) |
|
|
|
imap_exec (imap_t * imap, const char *fmt, ...) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -270,6 +297,12 @@ imap_exec (imap_t * imap, const char *fmt, ...) |
|
|
|
rec = &(*rec)->next; |
|
|
|
rec = &(*rec)->next; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
else if (!strcmp ("OK", arg) || !strcmp ("BAD", arg) || |
|
|
|
|
|
|
|
!strcmp ("NO", arg) || !strcmp ("PREAUTH", arg) || |
|
|
|
|
|
|
|
!strcmp ("BYE", arg)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
parse_response_code (imap, cmd); |
|
|
|
|
|
|
|
} |
|
|
|
else if ((arg1 = next_arg (&cmd))) |
|
|
|
else if ((arg1 = next_arg (&cmd))) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (!strcmp ("EXISTS", arg1)) |
|
|
|
if (!strcmp ("EXISTS", arg1)) |
|
|
@ -315,6 +348,7 @@ imap_exec (imap_t * imap, const char *fmt, ...) |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
arg = next_arg (&cmd); |
|
|
|
arg = next_arg (&cmd); |
|
|
|
|
|
|
|
parse_response_code (imap, cmd); |
|
|
|
if (!strcmp ("OK", arg)) |
|
|
|
if (!strcmp ("OK", arg)) |
|
|
|
return 0; |
|
|
|
return 0; |
|
|
|
return -1; |
|
|
|
return -1; |
|
|
@ -575,7 +609,7 @@ imap_fetch_message (imap_t * imap, unsigned int uid, int fd) |
|
|
|
size_t n; |
|
|
|
size_t n; |
|
|
|
char buf[1024]; |
|
|
|
char buf[1024]; |
|
|
|
|
|
|
|
|
|
|
|
send_server (imap->sock, "UID FETCH %d (RFC822.PEEK)", uid); |
|
|
|
send_server (imap->sock, "UID FETCH %d BODY.PEEK[]", uid); |
|
|
|
|
|
|
|
|
|
|
|
for (;;) |
|
|
|
for (;;) |
|
|
|
{ |
|
|
|
{ |
|
|
|