365 |
action_delete(mesgs, args); |
action_delete(mesgs, args); |
366 |
break; |
break; |
367 |
case FILTER_ACTION_COPY: |
case FILTER_ACTION_COPY: |
368 |
info("%d message%s copied to mailbox %s.\n", cnt, plural(cnt), |
info("%d message%s copied to mailbox \"%s\".\n", cnt, plural(cnt), |
369 |
destmbox); |
destmbox); |
370 |
action_copy(mesgs, apply_namespace(destmbox, namesp.prefix, |
action_copy(mesgs, apply_namespace(destmbox, namesp.prefix, |
371 |
namesp.delim), args); |
namesp.delim), args); |
372 |
break; |
break; |
373 |
case FILTER_ACTION_MOVE: |
case FILTER_ACTION_MOVE: |
374 |
info("%d message%s moved to mailbox %s.\n", cnt, plural(cnt), |
info("%d message%s moved to mailbox \"%s\".\n", cnt, plural(cnt), |
375 |
destmbox); |
destmbox); |
376 |
action_move(mesgs, apply_namespace(destmbox, namesp.prefix, |
action_move(mesgs, apply_namespace(destmbox, namesp.prefix, |
377 |
namesp.delim), args); |
namesp.delim), args); |
425 |
*/ |
*/ |
426 |
int action_copy(char *mesgs, char *destmbox, char *args) |
int action_copy(char *mesgs, char *destmbox, char *args) |
427 |
{ |
{ |
428 |
|
int r = 0; |
429 |
const char *delim = " "; |
const char *delim = " "; |
430 |
char *tok, *mcp, *m, *acp = NULL, *occur; |
char *tok, *mcp, *m, *acp = NULL, *occur; |
431 |
|
|
441 |
if (*args) |
if (*args) |
442 |
fetch_response(imap_fetch(tok, acp, 0)); |
fetch_response(imap_fetch(tok, acp, 0)); |
443 |
|
|
444 |
if (copy_response(imap_copy(tok, destmbox)) == RESPONSE_TRYCREATE) |
if ((r = copy_response(imap_copy(tok, destmbox))) == RESPONSE_TRYCREATE) |
445 |
if (!server_response(imap_create(destmbox))) |
if (!server_response(imap_create(destmbox))) |
446 |
copy_response(imap_copy(tok, destmbox)); |
r = copy_response(imap_copy(tok, destmbox)); |
447 |
} |
} |
448 |
|
|
449 |
free(mcp); |
free(mcp); |
451 |
if (*args) |
if (*args) |
452 |
free(acp); |
free(acp); |
453 |
|
|
454 |
return 0; |
return r; |
455 |
} |
} |
456 |
|
|
457 |
|
|
460 |
*/ |
*/ |
461 |
int action_move(char *mesgs, char *destmbox, char *args) |
int action_move(char *mesgs, char *destmbox, char *args) |
462 |
{ |
{ |
463 |
action_copy(mesgs, destmbox, args); |
if (!action_copy(mesgs, destmbox, args)) |
464 |
action_delete(mesgs, "\0"); |
action_delete(mesgs, "\0"); |
465 |
|
|
466 |
/* CLOSE -> SELECT much faster than EXPUNGE -> SELECT */ |
/* CLOSE -> SELECT much faster than EXPUNGE -> SELECT */ |
467 |
/* server_response(imap_expunge()); */ |
/* server_response(imap_expunge()); */ |