| 596 | | case OP_COMPOSE_ATTACH_MESSAGE: |
| 597 | | |
| 598 | | fname[0] = 0; |
| 599 | | { |
| 600 | | char* prompt; |
| 601 | | int flag; |
| 602 | | |
| 603 | | if (op == OP_COMPOSE_ATTACH_FILE) |
| 604 | | { |
| 605 | | prompt = _("Attach file"); |
| 606 | | flag = 0; |
| 607 | | numfiles = 0; |
| 608 | | files = NULL; |
| 609 | | if (_mutt_enter_fname (prompt, fname, sizeof (fname), &menu->redraw, flag, 1, &files, &numfiles) == -1) |
| 610 | | break; |
| 611 | | } |
| 612 | | else |
| 613 | | { |
| 614 | | prompt = _("Open mailbox to attach message from"); |
| 615 | | if (Context) |
| 616 | | { |
| 617 | | strfcpy (fname, NONULL (Context->path), sizeof (fname)); |
| 618 | | mutt_pretty_mailbox (fname); |
| 619 | | } |
| 620 | | flag = 1; |
| 621 | | if (mutt_enter_fname (prompt, fname, sizeof (fname), &menu->redraw, flag) == -1 || !fname[0]) |
| 622 | | break; |
| 623 | | mutt_expand_path (fname, sizeof (fname)); |
| 624 | | /* check to make sure the file exists and is readable */ |
| 625 | | if (access (fname, R_OK) == -1) |
| 626 | | { |
| 627 | | mutt_perror (fname); |
| 628 | | break; |
| 629 | | } |
| 630 | | } |
| 631 | | } |
| 632 | | |
| 633 | | if (op == OP_COMPOSE_ATTACH_MESSAGE) |
| 634 | | { |
| 635 | | menu->redraw = REDRAW_FULL; |
| 636 | | |
| 637 | | ctx = mx_open_mailbox (fname, M_READONLY, NULL); |
| 638 | | if (ctx == NULL) |
| 639 | | { |
| 640 | | mutt_perror (fname); |
| | 594 | { |
| | 595 | char *prompt, **files; |
| | 596 | int error, numfiles; |
| | 597 | |
| | 598 | fname[0] = 0; |
| | 599 | prompt = _("Attach file"); |
| | 600 | numfiles = 0; |
| | 601 | files = NULL; |
| | 602 | |
| | 603 | if (_mutt_enter_fname (prompt, fname, sizeof (fname), &menu->redraw, 0, 1, &files, &numfiles) == -1) |
| 642 | | } |
| 643 | | |
| 644 | | if (!ctx->msgcount) |
| 645 | | { |
| 646 | | mx_close_mailbox (ctx); |
| 647 | | safe_free ((void **) &ctx); |
| 648 | | mutt_error _("No messages in that folder."); |
| 649 | | break; |
| 650 | | } |
| 651 | | |
| 652 | | this = Context; /* remember current folder */ |
| 653 | | Context = ctx; |
| 654 | | set_option(OPTATTACHMSG); |
| 655 | | mutt_message _("Tag the messages you want to attach!"); |
| 656 | | close = mutt_index_menu (); |
| 657 | | unset_option(OPTATTACHMSG); |
| 658 | | |
| 659 | | if (!Context) |
| 660 | | { |
| 661 | | /* go back to the folder we started from */ |
| 662 | | Context = this; |
| 663 | | /* Restore old $sort and $sort_aux */ |
| 664 | | Sort = oldSort; |
| 665 | | SortAux = oldSortAux; |
| 666 | | menu->redraw |= REDRAW_INDEX | REDRAW_STATUS; |
| 667 | | break; |
| 668 | | } |
| 669 | | } |
| 670 | | |
| 671 | | { |
| 672 | | int numtag = 0; |
| 673 | | |
| 674 | | if (op == OP_COMPOSE_ATTACH_MESSAGE) |
| 675 | | numtag = Context->tagged; |
| 676 | | else |
| 677 | | numtag = numfiles; |
| 678 | | if (idxlen + numtag >= idxmax) |
| 679 | | { |
| 680 | | safe_realloc ((void **) &idx, sizeof (ATTACHPTR *) * (idxmax += 5 + numtag)); |
| | 605 | |
| | 606 | if (idxlen + numfiles >= idxmax) |
| | 607 | { |
| | 608 | safe_realloc ((void **) &idx, sizeof (ATTACHPTR *) * (idxmax += 5 + numfiles)); |
| | 641 | |
| | 642 | fname[0] = 0; |
| | 643 | prompt = _("Open mailbox to attach message from"); |
| | 644 | |
| | 645 | if (Context) |
| | 646 | { |
| | 647 | strfcpy (fname, NONULL (Context->path), sizeof (fname)); |
| | 648 | mutt_pretty_mailbox (fname); |
| | 649 | } |
| | 650 | |
| | 651 | if (mutt_enter_fname (prompt, fname, sizeof (fname), &menu->redraw, 1) == -1 || !fname[0]) |
| | 652 | break; |
| | 653 | |
| | 654 | mutt_expand_path (fname, sizeof (fname)); |
| | 655 | /* check to make sure the file exists and is readable */ |
| | 656 | if (access (fname, R_OK) == -1) |
| | 657 | { |
| | 658 | mutt_perror (fname); |
| | 659 | break; |
| | 660 | } |
| | 661 | |
| | 662 | menu->redraw = REDRAW_FULL; |
| | 663 | |
| | 664 | ctx = mx_open_mailbox (fname, M_READONLY, NULL); |
| | 665 | if (ctx == NULL) |
| | 666 | { |
| | 667 | mutt_perror (fname); |
| | 668 | break; |
| | 669 | } |
| | 670 | |
| | 671 | if (!ctx->msgcount) |
| | 672 | { |
| | 673 | mx_close_mailbox (ctx); |
| | 674 | safe_free ((void **) &ctx); |
| | 675 | mutt_error _("No messages in that folder."); |
| | 676 | break; |
| | 677 | } |
| | 678 | |
| | 679 | this = Context; /* remember current folder and sort methods*/ |
| | 680 | oldSort = Sort; oldSortAux = SortAux; |
| | 681 | |
| | 682 | Context = ctx; |
| | 683 | set_option(OPTATTACHMSG); |
| | 684 | mutt_message _("Tag the messages you want to attach!"); |
| | 685 | close = mutt_index_menu (); |
| | 686 | unset_option(OPTATTACHMSG); |
| | 687 | |
| | 688 | if (!Context) |
| | 689 | { |
| | 690 | /* go back to the folder we started from */ |
| | 691 | Context = this; |
| | 692 | /* Restore old $sort and $sort_aux */ |
| | 693 | Sort = oldSort; |
| | 694 | SortAux = oldSortAux; |
| | 695 | menu->redraw |= REDRAW_INDEX | REDRAW_STATUS; |
| | 696 | break; |
| | 697 | } |
| | 698 | |
| | 699 | if (idxlen + Context->tagged >= idxmax) |
| | 700 | { |
| | 701 | safe_realloc ((void **) &idx, sizeof (ATTACHPTR *) * (idxmax += 5 + Context->tagged)); |
| | 702 | menu->data = idx; |
| | 703 | } |
| | 704 | |