Changeset 842:e20c4487dc39 for browser.c
Legend:
- Unmodified
- Added
- Removed
-
browser.c
r775 r842 24 24 #include "sort.h" 25 25 #include "mailbox.h" 26 #include "browser.h" 27 #ifdef USE_IMAP 28 #include "imap.h" 29 #endif 26 30 27 31 #include <stdlib.h> … … 33 37 #include <pwd.h> 34 38 #include <grp.h> 35 36 struct folder_file37 {38 mode_t mode;39 time_t mtime;40 off_t size;41 char *name;42 char *desc;43 short tagged;44 };45 46 struct browser_state47 {48 struct folder_file *entry;49 short entrylen; /* number of real entries */50 short entrymax; /* max entry */51 };52 39 53 40 static struct mapping_t FolderHelp[] = { … … 457 444 strfcpy (path, LastDir, sizeof (path)); 458 445 mutt_pretty_mailbox (path); 446 #ifdef USE_IMAP 447 if (state->imap_browse && option (OPTIMAPLSUB)) 448 snprintf (title, titlelen, _("Subscribed [%s], File mask: %s"), 449 path, Mask.pattern); 450 else 451 #endif 459 452 snprintf (title, titlelen, _("Directory [%s], File mask: %s"), 460 453 path, Mask.pattern); … … 492 485 { 493 486 mutt_expand_path (f, flen); 487 #ifdef USE_IMAP 488 if (mx_is_imap (f)) 489 { 490 init_state (&state, NULL); 491 state.imap_browse = 1; 492 imap_init_browse (f, &state); 493 strfcpy (LastDir, f, sizeof (LastDir)); 494 } 495 else 496 { 497 #endif 494 498 for (i = mutt_strlen (f) - 1; i > 0 && f[i] != '/' ; i--); 495 499 if (i > 0) … … 521 525 strfcpy (prefix, f + i + 1, sizeof (prefix)); 522 526 killPrefix = 1; 523 } 524 else if (!LastDir[0]) 525 strfcpy (LastDir, NONULL(Maildir), sizeof (LastDir)); 527 #ifdef USE_IMAP 528 } 529 #endif 530 } 531 else 532 { 533 if (!LastDir[0]) 534 strfcpy (LastDir, NONULL(Maildir), sizeof (LastDir)); 535 #ifdef USE_IMAP 536 if (!buffy && mx_is_imap (LastDir)) 537 { 538 init_state (&state, NULL); 539 state.imap_browse = 1; 540 imap_init_browse (LastDir, &state); 541 } 542 #endif 543 } 526 544 527 545 *f = 0; … … 532 550 return; 533 551 } 534 else if (examine_directory (NULL, &state, LastDir, prefix) == -1) 552 else 553 #ifdef USE_IMAP 554 if (!state.imap_browse) 555 #endif 556 if (examine_directory (NULL, &state, LastDir, prefix) == -1) 535 557 return; 536 558 … … 562 584 if (S_ISDIR (state.entry[menu->current].mode) || 563 585 (S_ISLNK (state.entry[menu->current].mode) && 564 link_is_dir (state.entry[menu->current].name))) 586 link_is_dir (state.entry[menu->current].name)) 587 #ifdef USE_IMAP 588 || state.entry[menu->current].notfolder 589 #endif 590 ) 565 591 { 566 592 /* make sure this isn't a MH or maildir mailbox */ … … 570 596 mutt_expand_path (buf, sizeof (buf)); 571 597 } 598 #ifdef USE_IMAP 599 else if (state.imap_browse) 600 { 601 strfcpy (buf, state.entry[menu->current].name, sizeof (buf)); 602 } 603 #endif 572 604 else 573 605 snprintf (buf, sizeof (buf), "%s/%s", LastDir, 574 606 state.entry[menu->current].name); 575 607 576 if (mx_get_magic (buf) <= 0) 608 if ((mx_get_magic (buf) <= 0) 609 #ifdef USE_IMAP 610 || state.entry[menu->current].notfolder 611 #endif 612 ) 577 613 { 578 614 char OldLastDir[_POSIX_PATH_MAX]; … … 605 641 mutt_expand_path (LastDir, sizeof (LastDir)); 606 642 } 643 #ifdef USE_IMAP 644 else if (state.imap_browse) 645 { 646 strfcpy (LastDir, state.entry[menu->current].name, 647 sizeof (LastDir)); 648 } 649 #endif 607 650 else 608 651 sprintf (LastDir + mutt_strlen (LastDir), "/%s", … … 616 659 } 617 660 buffy = 0; 661 #ifdef USE_IMAP 662 if (state.imap_browse) 663 { 664 init_state (&state, NULL); 665 state.imap_browse = 1; 666 imap_init_browse (LastDir, &state); 667 menu->data = state.entry; 668 } 669 else 670 #endif 618 671 if (examine_directory (menu, &state, LastDir, prefix) == -1) 619 672 { … … 638 691 mutt_expand_path (f, flen); 639 692 } 693 #ifdef USE_IMAP 694 else if (state.imap_browse) 695 { 696 strfcpy (f, state.entry[menu->current].name, flen); 697 } 698 #endif 640 699 else 641 700 snprintf (f, flen, "%s/%s", LastDir, state.entry[menu->current].name); … … 685 744 mutt_message(state.entry[menu->current].name); 686 745 break; 746 747 #ifdef USE_IMAP 748 case OP_BROWSER_SUBSCRIBE: 749 imap_subscribe (state.entry[menu->current].name, 1); 750 break; 751 752 case OP_BROWSER_UNSUBSCRIBE: 753 imap_subscribe (state.entry[menu->current].name, 0); 754 break; 755 756 case OP_BROWSER_TOGGLE_LSUB: 757 if (option (OPTIMAPLSUB)) 758 { 759 unset_option (OPTIMAPLSUB); 760 } 761 else 762 { 763 set_option (OPTIMAPLSUB); 764 } 765 mutt_ungetch (0, OP_CHECK_NEW); 766 break; 767 #endif 687 768 688 769 case OP_CHANGE_DIRECTORY: 689 770 690 771 strfcpy (buf, LastDir, sizeof (buf)); 772 #ifdef USE_IMAP 773 if (!state.imap_browse) 774 #endif 691 775 {/* add '/' at the end of the directory name */ 692 776 int len=mutt_strlen(LastDir); … … 700 784 buffy = 0; 701 785 mutt_expand_path (buf, sizeof (buf)); 786 #ifdef USE_IMAP 787 if (mx_is_imap (buf)) 788 { 789 strfcpy (LastDir, buf, sizeof (LastDir)); 790 destroy_state (&state); 791 init_state (&state, NULL); 792 state.imap_browse = 1; 793 imap_init_browse (LastDir, &state); 794 menu->data = state.entry; 795 menu->current = 0; 796 menu->top = 0; 797 init_menu (&state, menu, title, sizeof (title), buffy); 798 } 799 else 800 #endif 702 801 if (stat (buf, &st) == 0) 703 802 { … … 835 934 prefix[0] = 0; 836 935 killPrefix = 0; 936 837 937 if (buffy) 838 938 { … … 840 940 return; 841 941 } 942 #ifdef USE_IMAP 943 else if (mx_is_imap (LastDir)) 944 { 945 init_state (&state, NULL); 946 state.imap_browse = 1; 947 imap_init_browse (LastDir, &state); 948 menu->data = state.entry; 949 } 950 #endif 842 951 else if (examine_directory (menu, &state, LastDir, prefix) == -1) 843 952 return;
