mirror of
https://bitbucket.org/jsuto/piler.git
synced 2024-12-25 08:30:12 +01:00
fix a Noselect imap folder problem
Change-Id: I128fbeb45c56f7d456cac5c71d5a0c31de263976 Signed-off-by: SJ <sj@acts.hu>
This commit is contained in:
parent
1ebd49956a
commit
3be31d52ac
38
src/imap.c
38
src/imap.c
@ -99,7 +99,10 @@ int process_imap_folder(int sd, int *seq, char *folder, struct session_data *sda
|
||||
|
||||
/* imap cmd: SELECT */
|
||||
|
||||
if(strchr(folder, '"'))
|
||||
snprintf(buf, sizeof(buf)-1, "A%d SELECT %s\r\n", *seq, folder);
|
||||
else
|
||||
snprintf(buf, sizeof(buf)-1, "A%d SELECT \"%s\"\r\n", *seq, folder);
|
||||
|
||||
write1(sd, buf, strlen(buf), use_ssl, data->ssl);
|
||||
if(read_response(sd, buf, sizeof(buf), seq, data, use_ssl) == 0){
|
||||
@ -394,6 +397,7 @@ void send_imap_close(int sd, int *seq, struct __data *data, int use_ssl){
|
||||
|
||||
int list_folders(int sd, int *seq, int use_ssl, struct __data *data){
|
||||
char *p, *q, *r, *buf, *ruf, tag[SMALLBUFSIZE], tagok[SMALLBUFSIZE], puf[MAXBUFSIZE];
|
||||
char attrs[SMALLBUFSIZE];
|
||||
int len=MAXBUFSIZE+3, pos=0, n, rc=ERR, fldrlen=0, result;
|
||||
|
||||
printf("List of IMAP folders:\n");
|
||||
@ -409,6 +413,8 @@ int list_folders(int sd, int *seq, int use_ssl, struct __data *data){
|
||||
|
||||
write1(sd, puf, strlen(puf), use_ssl, data->ssl);
|
||||
|
||||
p = NULL;
|
||||
|
||||
while(1){
|
||||
n = recvtimeoutssl(sd, puf, sizeof(puf), data->import->timeout, use_ssl, data->ssl);
|
||||
if(n < 0) return ERR;
|
||||
@ -428,9 +434,14 @@ int list_folders(int sd, int *seq, int use_ssl, struct __data *data){
|
||||
memcpy(buf + pos, puf, n);
|
||||
pos += n;
|
||||
|
||||
if(strstr(buf, tagok)) break;
|
||||
p = strstr(buf, tagok);
|
||||
if(p) break;
|
||||
}
|
||||
|
||||
// trim the "A3 OK LIST completed" trailer off
|
||||
if(p) *p = '\0';
|
||||
|
||||
memset(attrs, 0, sizeof(attrs));
|
||||
|
||||
p = buf;
|
||||
do {
|
||||
@ -446,6 +457,9 @@ int list_folders(int sd, int *seq, int use_ssl, struct __data *data){
|
||||
q = strstr(puf, ") \"");
|
||||
if(q){
|
||||
if (!fldrlen) {
|
||||
*q = '\0';
|
||||
snprintf(attrs, sizeof(attrs)-1, "%s", &puf[8]);
|
||||
|
||||
q += 3;
|
||||
while(*q != '"') q++;
|
||||
q++;
|
||||
@ -469,21 +483,29 @@ int list_folders(int sd, int *seq, int use_ssl, struct __data *data){
|
||||
}
|
||||
r++;
|
||||
}
|
||||
|
||||
if(!strstr(attrs, "\\Noselect")){
|
||||
addnode(data->imapfolders, ruf);
|
||||
printf("=> '%s'\n", ruf);
|
||||
}
|
||||
else printf("skipping ");
|
||||
|
||||
printf("=> '%s' {%d} [%s]\n", ruf, fldrlen, attrs);
|
||||
|
||||
free(ruf);
|
||||
fldrlen = 0;
|
||||
} else {
|
||||
if(!strstr(attrs, "\\Noselect")){
|
||||
addnode(data->imapfolders, q);
|
||||
printf("=> '%s'\n", q);
|
||||
}
|
||||
else printf("skipping ");
|
||||
|
||||
printf("=> '%s [%s]'\n", q, attrs);
|
||||
}
|
||||
|
||||
memset(attrs, 0, sizeof(attrs));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(strncmp(puf, tagok, strlen(tagok)) == 0) {}
|
||||
}
|
||||
|
||||
} while(p);
|
||||
|
Loading…
Reference in New Issue
Block a user