OP_VERSION is useless.
[apps/madmutt.git] / lib-ui / curs_main.c
index 257cd96..4a8a2be 100644 (file)
@@ -11,8 +11,6 @@
  */
 
 #include <lib-ui/lib-ui.h>
-
-#include <lib-ui/sidebar.h>
 #include <lib-mx/mx.h>
 #include "pop.h"
 
 
 #include <imap/imap_private.h>
 
-#ifdef USE_NNTP
-#include "nntp.h"
-#endif
-
 static const char *No_mailbox_is_open = N_("No mailbox is open.");
 static const char *There_are_no_messages = N_("There are no messages.");
 static const char *Mailbox_is_read_only = N_("Mailbox is read-only.");
@@ -553,13 +547,13 @@ int mutt_index_menu (void)
         tag = 1;
 
         /* give visual indication that the next command is a tag- command */
-        mvwaddstr (main_w, LINES - 1, 0, "tag-");
-        wclrtoeol (main_w);
+        mvwaddstr (stdscr, LINES - 1, 0, "tag-");
+        wclrtoeol (stdscr);
 
         /* get the real command */
         if ((op = km_dokey (MENU_MAIN)) == OP_TAG_PREFIX) {
           /* abort tag sequence */
-          CLEARLINE(main_w, LINES - 1);
+          CLEARLINE(stdscr, LINES - 1);
           continue;
         }
       }
@@ -588,20 +582,19 @@ int mutt_index_menu (void)
         tag = 1;
 
         /* give visual indication that the next command is a tag- command */
-        mvwaddstr (main_w, LINES - 1, 0, "tag-");
-        wclrtoeol (main_w);
+        mvwaddstr (stdscr, LINES - 1, 0, "tag-");
+        wclrtoeol (stdscr);
 
         /* get the real command */
         if ((op = km_dokey (MENU_MAIN)) == OP_TAG_PREFIX) {
           /* abort tag sequence */
-          CLEARLINE(main_w, LINES - 1);
+          CLEARLINE(stdscr, LINES - 1);
           continue;
         }
       }
 
       mutt_clear_error ();
-    }
-    else {
+    } else {
       if (menu->current < menu->max)
         menu->oldcurrent = menu->current;
       else
@@ -610,10 +603,6 @@ int mutt_index_menu (void)
       mutt_curs_set (1);        /* fallback from the pager */
     }
 
-#ifdef USE_NNTP
-    unset_option (OPTNEWS);     /* for any case */
-#endif
-
     switch (op) {
 
       /* ----------------------------------------------------------------------
@@ -663,112 +652,7 @@ int mutt_index_menu (void)
       menu_current_bottom (menu);
       break;
 
-#ifdef USE_NNTP
-    case OP_GET_MESSAGE:
-    case OP_GET_PARENT:
-      CHECK_MSGCOUNT;
-      if (Context->magic == M_NNTP) {
-        HEADER *h;
-
-        if (op == OP_GET_MESSAGE) {
-          buf[0] = 0;
-          if (mutt_get_field (_("Enter Message-ID: "), buf, sizeof (buf), 0)
-              != 0 || !buf[0])
-            break;
-        }
-        else {
-          string_list_t *ref = CURHDR->env->references;
-
-          if (!ref) {
-            mutt_error (_("Article has no parent reference!"));
-
-            break;
-          }
-          m_strcpy(buf, sizeof(buf), ref->data);
-        }
-        if (!Context->id_hash)
-          Context->id_hash = mutt_make_id_hash (Context);
-        if ((h = hash_find (Context->id_hash, buf))) {
-          if (h->virtual != -1) {
-            menu->current = h->virtual;
-            menu->redraw = REDRAW_MOTION_RESYNCH;
-          }
-          else if (h->collapsed) {
-            mutt_uncollapse_thread (Context, h);
-            mutt_set_virtual (Context);
-            menu->current = h->virtual;
-            menu->redraw = REDRAW_MOTION_RESYNCH;
-          }
-          else
-            mutt_error (_("Message not visible in limited view."));
-        }
-        else {
-          if (nntp_check_msgid (Context, buf) == 0) {
-            h = Context->hdrs[Context->msgcount - 1];
-            mutt_sort_headers (Context, 0);
-            menu->current = h->virtual;
-            menu->redraw = REDRAW_FULL;
-          }
-          else
-            mutt_error (_("Article %s not found on server"), buf);
-        }
-      }
-      break;
-
-    case OP_GET_CHILDREN:
-    case OP_RECONSTRUCT_THREAD:
-      CHECK_MSGCOUNT;
-      if (Context->magic == M_NNTP) {
-        HEADER *h;
-        int old = CURHDR->index;
-
-        if (!CURHDR->env->message_id) {
-          mutt_error (_("No Message-ID. Unable to perform operation"));
-
-          break;
-        }
-
-        if (!Context->id_hash)
-          Context->id_hash = mutt_make_id_hash (Context);
-        m_strcpy(buf, sizeof(buf), CURHDR->env->message_id);
-
-        if (op == OP_RECONSTRUCT_THREAD) {
-          string_list_t *ref = CURHDR->env->references;
-
-          while (ref) {
-            nntp_check_msgid (Context, ref->data);
-            /* the last msgid in References is the root message */
-            if (!ref->next)
-              m_strcpy(buf, sizeof(buf), ref->data);
-            ref = ref->next;
-          }
-        }
-        mutt_message (_("Check for children of message..."));
-
-        if (nntp_check_children (Context, buf) == 0) {
-          mutt_sort_headers (Context, (op == OP_RECONSTRUCT_THREAD));
-          h = hash_find (Context->id_hash, buf);
-          /* if the root message was retrieved, move to it */
-          if (h)
-            menu->current = h->virtual;
-          else                  /* try to restore old position */
-            for (i = 0; i < Context->msgcount; i++)
-              if (Context->hdrs[i]->index == old) {
-                menu->current = Context->hdrs[i]->virtual;
-                /* As an added courtesy, recenter the menu
-                 * with the current entry at the middle of the screen */
-                menu_check_recenter (menu);
-                menu_current_middle (menu);
-              }
-        }
-        menu->redraw = REDRAW_FULL;
-        mutt_clear_error ();
-      }
-      break;
-#endif
-
     case OP_JUMP:
-
       CHECK_MSGCOUNT;
       CHECK_VISIBLE;
       if (isdigit (LastKey))
@@ -819,7 +703,6 @@ int mutt_index_menu (void)
        */
 
     case OP_MAIN_DELETE_PATTERN:
-
       CHECK_MSGCOUNT;
       CHECK_VISIBLE;
       CHECK_READONLY;
@@ -832,14 +715,12 @@ int mutt_index_menu (void)
       break;
 
     case OP_MAIN_FETCH_MAIL:
-
       CHECK_ATTACH;
       pop_fetch_mail ();
       menu->redraw = REDRAW_FULL;
       break;
 
     case OP_HELP:
-
       mutt_help (MENU_MAIN);
       menu->redraw = REDRAW_FULL;
       break;
@@ -860,7 +741,6 @@ int mutt_index_menu (void)
 
     case OP_MAIN_LIMIT:
     case OP_TOGGLE_READ:
-
       CHECK_IN_MAILBOX;
       menu->oldcurrent = (Context->vcount && menu->current >= 0
                           && menu->current <
@@ -908,7 +788,6 @@ int mutt_index_menu (void)
       break;
 
     case OP_QUIT:
-
       closed = op;
       if (attach_msg) {
         done = 1;
@@ -942,7 +821,6 @@ int mutt_index_menu (void)
     case OP_SEARCH_REVERSE:
     case OP_SEARCH_NEXT:
     case OP_SEARCH_OPPOSITE:
-
       CHECK_MSGCOUNT;
       CHECK_VISIBLE;
       if ((menu->current = mutt_search_command (menu->current, op)) == -1)
@@ -953,7 +831,6 @@ int mutt_index_menu (void)
 
     case OP_SORT:
     case OP_SORT_REVERSE:
-
       if (mutt_select_sort ((op == OP_SORT_REVERSE)) == 0) {
         if (Context && Context->msgcount) {
           resort_index (menu);
@@ -963,7 +840,6 @@ int mutt_index_menu (void)
       break;
 
     case OP_TAG:
-
       CHECK_MSGCOUNT;
       CHECK_VISIBLE;
       if (tag && !option (OPTAUTOTAG)) {
@@ -987,7 +863,6 @@ int mutt_index_menu (void)
       break;
 
     case OP_MAIN_TAG_PATTERN:
-
       CHECK_MSGCOUNT;
       CHECK_VISIBLE;
       mutt_pattern_func (M_TAG, _("Tag messages matching: "));
@@ -995,7 +870,6 @@ int mutt_index_menu (void)
       break;
 
     case OP_MAIN_UNDELETE_PATTERN:
-
       CHECK_MSGCOUNT;
       CHECK_VISIBLE;
       CHECK_READONLY;
@@ -1008,7 +882,6 @@ int mutt_index_menu (void)
       break;
 
     case OP_MAIN_UNTAG_PATTERN:
-
       CHECK_MSGCOUNT;
       CHECK_VISIBLE;
       if (mutt_pattern_func (M_UNTAG, _("Untag messages matching: ")) == 0)
@@ -1025,7 +898,6 @@ int mutt_index_menu (void)
       break;
 
     case OP_MAIN_SYNC_FOLDER:
-
       if (Context && !Context->msgcount)
         break;
 
@@ -1078,15 +950,7 @@ int mutt_index_menu (void)
     case OP_SIDEBAR_OPEN:
     case OP_MAIN_CHANGE_FOLDER:
     case OP_MAIN_CHANGE_FOLDER_READONLY:
-#ifdef USE_NNTP
-    case OP_MAIN_CHANGE_GROUP:
-    case OP_MAIN_CHANGE_GROUP_READONLY:
-#endif
-      if (attach_msg ||
-#ifdef USE_NNTP
-          op == OP_MAIN_CHANGE_GROUP_READONLY ||
-#endif
-          op == OP_MAIN_CHANGE_FOLDER_READONLY)
+      if (attach_msg || op == OP_MAIN_CHANGE_FOLDER_READONLY)
         flags = M_READONLY;
       else
         flags = 0;
@@ -1097,26 +961,10 @@ int mutt_index_menu (void)
         cp = _("Open mailbox");
 
       buf[0] = '\0';
-#ifdef USE_NNTP
-      unset_option (OPTNEWS);
-      if (op == OP_MAIN_CHANGE_GROUP || op == OP_MAIN_CHANGE_GROUP_READONLY) {
-        set_option (OPTNEWS);
-        if (!(CurrentNewsSrv = mutt_select_newsserver (NewsServer)))
-          break;
-        if (flags)
-          cp = _("Open newsgroup in read-only mode");
-        else
-          cp = _("Open newsgroup");
-        nntp_buffy (buf, sizeof (buf));
-      }
-      else
-#endif
-      {
-        if (Context && Context->path)
-          m_strcpy(buf, sizeof(buf), Context->path);
-        if (op != OP_SIDEBAR_OPEN)
-          buffy_next (buf, sizeof (buf));
-      }
+      if (Context && Context->path)
+        m_strcpy(buf, sizeof(buf), Context->path);
+      if (op != OP_SIDEBAR_OPEN)
+        buffy_next (buf, sizeof (buf));
 
       if (op == OP_SIDEBAR_OPEN) {
         m_strcpy(buf, sizeof(buf), sidebar_get_current());
@@ -1133,14 +981,7 @@ int mutt_index_menu (void)
         break;
       }
 
-#ifdef USE_NNTP
-      if (option (OPTNEWS)) {
-        unset_option (OPTNEWS);
-        nntp_expand_path (buf, sizeof (buf), &CurrentNewsSrv->conn->account);
-      }
-      else
-#endif
-        mutt_expand_path (buf, sizeof (buf));
+      mutt_expand_path (buf, sizeof (buf));
       if (mx_get_magic (buf) <= 0) {
         mutt_error (_("%s is not a mailbox."), buf);
         break;
@@ -1225,7 +1066,6 @@ int mutt_index_menu (void)
       continue;
 
     case OP_EXIT:
-
       closed = op;
       if (menu->menu == MENU_MAIN && attach_msg) {
         done = 1;
@@ -1245,7 +1085,6 @@ int mutt_index_menu (void)
       break;
 
     case OP_EDIT_TYPE:
-
       CHECK_MSGCOUNT;
       CHECK_VISIBLE;
       CHECK_ATTACH;
@@ -1260,7 +1099,6 @@ int mutt_index_menu (void)
       break;
 
     case OP_MAIN_BREAK_THREAD:
-
       CHECK_MSGCOUNT;
       CHECK_VISIBLE;
       CHECK_READONLY;
@@ -1290,7 +1128,6 @@ int mutt_index_menu (void)
       break;
 
     case OP_MAIN_LINK_THREADS:
-
       CHECK_MSGCOUNT;
       CHECK_VISIBLE;
       CHECK_READONLY;
@@ -1328,7 +1165,6 @@ int mutt_index_menu (void)
       break;
 
     case OP_MAIN_NEXT_UNDELETED:
-
       CHECK_MSGCOUNT;
       CHECK_VISIBLE;
       if (menu->current >= Context->vcount - 1) {
@@ -1351,7 +1187,6 @@ int mutt_index_menu (void)
       break;
 
     case OP_NEXT_ENTRY:
-
       CHECK_MSGCOUNT;
       CHECK_VISIBLE;
       if (menu->current >= Context->vcount - 1) {
@@ -1370,7 +1205,6 @@ int mutt_index_menu (void)
       break;
 
     case OP_MAIN_PREV_UNDELETED:
-
       CHECK_MSGCOUNT;
       CHECK_VISIBLE;
       if (menu->current < 1) {
@@ -1392,7 +1226,6 @@ int mutt_index_menu (void)
       break;
 
     case OP_PREV_ENTRY:
-
       CHECK_MSGCOUNT;
       CHECK_VISIBLE;
       if (menu->current < 1) {
@@ -1451,7 +1284,6 @@ int mutt_index_menu (void)
     case OP_MAIN_PREV_UNREAD:
     case OP_MAIN_NEXT_NEW_THEN_UNREAD:
     case OP_MAIN_PREV_NEW_THEN_UNREAD:
-
       {
         int first_unread = -1;
         int first_new = -1;
@@ -1533,7 +1365,6 @@ int mutt_index_menu (void)
         break;
       }
     case OP_FLAG_MESSAGE:
-
       CHECK_MSGCOUNT;
       CHECK_VISIBLE;
       CHECK_READONLY;
@@ -1566,7 +1397,6 @@ int mutt_index_menu (void)
       break;
 
     case OP_TOGGLE_NEW:
-
       CHECK_MSGCOUNT;
       CHECK_VISIBLE;
       CHECK_READONLY;
@@ -1608,7 +1438,6 @@ int mutt_index_menu (void)
       break;
 
     case OP_TOGGLE_WRITE:
-
       CHECK_IN_MAILBOX;
       if (mx_toggle_write (Context) == 0)
         menu->redraw |= REDRAW_STATUS;
@@ -1618,7 +1447,6 @@ int mutt_index_menu (void)
     case OP_MAIN_NEXT_SUBTHREAD:
     case OP_MAIN_PREV_THREAD:
     case OP_MAIN_PREV_SUBTHREAD:
-
       CHECK_MSGCOUNT;
       CHECK_VISIBLE;
       switch (op) {
@@ -1656,7 +1484,6 @@ int mutt_index_menu (void)
       break;
 
     case OP_MAIN_PARENT_MESSAGE:
-
       CHECK_MSGCOUNT;
       CHECK_VISIBLE;
 
@@ -1673,7 +1500,6 @@ int mutt_index_menu (void)
 
     case OP_MAIN_SET_FLAG:
     case OP_MAIN_CLEAR_FLAG:
-
       CHECK_MSGCOUNT;
       CHECK_VISIBLE;
       CHECK_READONLY;
@@ -1782,7 +1608,6 @@ int mutt_index_menu (void)
        */
 
     case OP_BOUNCE_MESSAGE:
-
       CHECK_ATTACH;
       CHECK_MSGCOUNT;
       CHECK_VISIBLE;
@@ -1790,7 +1615,6 @@ int mutt_index_menu (void)
       break;
 
     case OP_CREATE_ALIAS:
-
       mutt_create_alias (Context
                          && Context->vcount ? CURHDR->env : NULL, NULL);
       MAYBE_REDRAW (menu->redraw);
@@ -1805,7 +1629,6 @@ int mutt_index_menu (void)
 
     case OP_PURGE_MESSAGE:
     case OP_DELETE:
-
       CHECK_MSGCOUNT;
       CHECK_VISIBLE;
       CHECK_READONLY;
@@ -1845,7 +1668,6 @@ int mutt_index_menu (void)
 
     case OP_DELETE_THREAD:
     case OP_DELETE_SUBTHREAD:
-
       CHECK_MSGCOUNT;
       CHECK_VISIBLE;
       CHECK_READONLY;
@@ -1866,25 +1688,13 @@ int mutt_index_menu (void)
       }
       break;
 
-#ifdef USE_NNTP
-    case OP_CATCHUP:
-      if (Context && Context->magic == M_NNTP) {
-        if (mutt_newsgroup_catchup (CurrentNewsSrv,
-                                    ((nntp_data_t *) Context->data)->group))
-          menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
-      }
-      break;
-#endif
-
     case OP_DISPLAY_ADDRESS:
-
       CHECK_MSGCOUNT;
       CHECK_VISIBLE;
       mutt_display_address (CURHDR->env);
       break;
 
     case OP_ENTER_COMMAND:
-
       CurrentMenu = MENU_MAIN;
       mutt_enter_command ();
       mutt_check_rescore (Context);
@@ -1895,7 +1705,6 @@ int mutt_index_menu (void)
       break;
 
     case OP_EDIT_MESSAGE:
-
       CHECK_MSGCOUNT;
       CHECK_VISIBLE;
       CHECK_READONLY;
@@ -1911,7 +1720,6 @@ int mutt_index_menu (void)
       break;
 
     case OP_FORWARD_MESSAGE:
-
       CHECK_MSGCOUNT;
       CHECK_VISIBLE;
       CHECK_ATTACH;
@@ -1923,7 +1731,6 @@ int mutt_index_menu (void)
       break;
 
     case OP_GROUP_REPLY:
-
       CHECK_MSGCOUNT;
       CHECK_VISIBLE;
       CHECK_ATTACH;
@@ -1937,7 +1744,6 @@ int mutt_index_menu (void)
       break;
 
     case OP_LIST_REPLY:
-
       CHECK_ATTACH;
       CHECK_MSGCOUNT;
       CHECK_VISIBLE;
@@ -1951,7 +1757,6 @@ int mutt_index_menu (void)
       break;
 
     case OP_MAIL:
-
       CHECK_ATTACH;
       ci_send_message (0, NULL, NULL, Context, NULL);
       menu->redraw = REDRAW_FULL;
@@ -2013,14 +1818,12 @@ int mutt_index_menu (void)
       break;
 
     case OP_RECALL_MESSAGE:
-
       CHECK_ATTACH;
       ci_send_message (SENDPOSTPONED, NULL, NULL, Context, NULL);
       menu->redraw = REDRAW_FULL;
       break;
 
     case OP_RESEND:
-
       CHECK_ATTACH;
       CHECK_MSGCOUNT;
       CHECK_VISIBLE;
@@ -2038,47 +1841,7 @@ int mutt_index_menu (void)
       menu->redraw = REDRAW_FULL;
       break;
 
-#ifdef USE_NNTP
-    case OP_POST:
-    case OP_FOLLOWUP:
-    case OP_FORWARD_TO_GROUP:
-
-      CHECK_ATTACH;
-      if ((op == OP_FOLLOWUP || op == OP_FORWARD_TO_GROUP) &&
-          Context && Context->msgcount == 0) {
-        mutt_error (_("There are no messages."));
-        sleep (2);
-      }
-      else if (op != OP_FOLLOWUP || !CURHDR->env->followup_to ||
-               m_strcasecmp(CURHDR->env->followup_to, "poster") ||
-               query_quadoption (OPT_FOLLOWUPTOPOSTER,
-                                 _("Reply by mail as poster prefers?")) !=
-               M_YES) {
-        if (Context && Context->magic == M_NNTP
-            && !((nntp_data_t *) Context->data)->allowed
-            && query_quadoption (OPT_TOMODERATED,
-                                 _
-                                 ("Posting to this group not allowed, may be moderated. Continue?"))
-            != M_YES)
-          break;
-        if (op == OP_POST)
-          ci_send_message (SENDNEWS, NULL, NULL, Context, NULL);
-        else {
-          CHECK_MSGCOUNT;
-          if (op == OP_FOLLOWUP)
-            ci_send_message (SENDNEWS | SENDREPLY, NULL, NULL, Context,
-                             tag ? NULL : CURHDR);
-          else
-            ci_send_message (SENDNEWS | SENDFORWARD, NULL, NULL, Context,
-                             tag ? NULL : CURHDR);
-        }
-        menu->redraw = REDRAW_FULL;
-        break;
-      }
-#endif
-
     case OP_REPLY:
-
       CHECK_ATTACH;
       CHECK_MSGCOUNT;
       CHECK_VISIBLE;
@@ -2091,14 +1854,12 @@ int mutt_index_menu (void)
       break;
 
     case OP_SHELL_ESCAPE:
-
       mutt_shell_escape ();
       MAYBE_REDRAW (menu->redraw);
       break;
 
     case OP_TAG_THREAD:
     case OP_TAG_SUBTHREAD:
-
       CHECK_MSGCOUNT;
       CHECK_VISIBLE;
       rc = mutt_thread_set_flag (CURHDR, M_TAG, !CURHDR->tagged,
@@ -2116,7 +1877,6 @@ int mutt_index_menu (void)
       break;
 
     case OP_UNDELETE:
-
       CHECK_MSGCOUNT;
       CHECK_VISIBLE;
       CHECK_READONLY;
@@ -2143,7 +1903,6 @@ int mutt_index_menu (void)
 
     case OP_UNDELETE_THREAD:
     case OP_UNDELETE_SUBTHREAD:
-
       CHECK_MSGCOUNT;
       CHECK_VISIBLE;
       CHECK_READONLY;
@@ -2169,10 +1928,6 @@ int mutt_index_menu (void)
       }
       break;
 
-    case OP_VERSION:
-      mutt_version ();
-      break;
-
     case OP_BUFFY_LIST:
       if (option (OPTFORCEBUFFYCHECK))
         buffy_check (1);
@@ -2192,10 +1947,6 @@ int mutt_index_menu (void)
     case OP_END_COND:
       break;
 
-    case OP_WHAT_KEY:
-      mutt_what_key ();
-      break;
-
     case OP_SIDEBAR_SCROLL_UP:
     case OP_SIDEBAR_SCROLL_DOWN:
     case OP_SIDEBAR_NEXT:
@@ -2204,6 +1955,7 @@ int mutt_index_menu (void)
     case OP_SIDEBAR_PREV_NEW:
       sidebar_scroll (op);
       break;
+
     default:
       if (menu->menu == MENU_MAIN)
         km_error_key (MENU_MAIN);
@@ -2221,10 +1973,6 @@ int mutt_index_menu (void)
   if (!attach_msg) {
   /* Close all open IMAP connections */
     imap_logout_all ();
-#ifdef USE_NNTP
-  /* Close all open NNTP connections */
-    nntp_logout_all ();
-#endif
   }
 
   mutt_menuDestroy (&menu);