mirror of
https://bitbucket.org/jsuto/piler.git
synced 2024-12-25 09:10: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
42
src/imap.c
42
src/imap.c
@ -99,7 +99,10 @@ int process_imap_folder(int sd, int *seq, char *folder, struct session_data *sda
|
|||||||
|
|
||||||
/* imap cmd: SELECT */
|
/* imap cmd: SELECT */
|
||||||
|
|
||||||
snprintf(buf, sizeof(buf)-1, "A%d SELECT %s\r\n", *seq, folder);
|
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);
|
write1(sd, buf, strlen(buf), use_ssl, data->ssl);
|
||||||
if(read_response(sd, buf, sizeof(buf), seq, data, use_ssl) == 0){
|
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){
|
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 *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;
|
int len=MAXBUFSIZE+3, pos=0, n, rc=ERR, fldrlen=0, result;
|
||||||
|
|
||||||
printf("List of IMAP folders:\n");
|
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);
|
write1(sd, puf, strlen(puf), use_ssl, data->ssl);
|
||||||
|
|
||||||
|
p = NULL;
|
||||||
|
|
||||||
while(1){
|
while(1){
|
||||||
n = recvtimeoutssl(sd, puf, sizeof(puf), data->import->timeout, use_ssl, data->ssl);
|
n = recvtimeoutssl(sd, puf, sizeof(puf), data->import->timeout, use_ssl, data->ssl);
|
||||||
if(n < 0) return ERR;
|
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);
|
memcpy(buf + pos, puf, n);
|
||||||
pos += 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;
|
p = buf;
|
||||||
do {
|
do {
|
||||||
@ -446,6 +457,9 @@ int list_folders(int sd, int *seq, int use_ssl, struct __data *data){
|
|||||||
q = strstr(puf, ") \"");
|
q = strstr(puf, ") \"");
|
||||||
if(q){
|
if(q){
|
||||||
if (!fldrlen) {
|
if (!fldrlen) {
|
||||||
|
*q = '\0';
|
||||||
|
snprintf(attrs, sizeof(attrs)-1, "%s", &puf[8]);
|
||||||
|
|
||||||
q += 3;
|
q += 3;
|
||||||
while(*q != '"') q++;
|
while(*q != '"') q++;
|
||||||
q++;
|
q++;
|
||||||
@ -469,22 +483,30 @@ int list_folders(int sd, int *seq, int use_ssl, struct __data *data){
|
|||||||
}
|
}
|
||||||
r++;
|
r++;
|
||||||
}
|
}
|
||||||
addnode(data->imapfolders, ruf);
|
|
||||||
printf("=> '%s'\n", ruf);
|
if(!strstr(attrs, "\\Noselect")){
|
||||||
|
addnode(data->imapfolders, ruf);
|
||||||
|
}
|
||||||
|
else printf("skipping ");
|
||||||
|
|
||||||
|
printf("=> '%s' {%d} [%s]\n", ruf, fldrlen, attrs);
|
||||||
|
|
||||||
free(ruf);
|
free(ruf);
|
||||||
fldrlen = 0;
|
fldrlen = 0;
|
||||||
} else {
|
} else {
|
||||||
addnode(data->imapfolders, q);
|
if(!strstr(attrs, "\\Noselect")){
|
||||||
printf("=> '%s'\n", q);
|
addnode(data->imapfolders, 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);
|
} while(p);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user