]> git.decadent.org.uk Git - ap-utils.git/blobdiff - lib/aps.c
Imported Upstream version 1.5~pre1
[ap-utils.git] / lib / aps.c
index b99ad57ea5ffcfcbd9e8180ca02065cc7cf24d16..585b2477c675e69d5d8b8fa7fa47371f3983b3c4 100644 (file)
--- a/lib/aps.c
+++ b/lib/aps.c
 #include <fcntl.h>
 #include <stdlib.h>
 #include "ap-utils.h"
-#include "ap-curses.h"
 
-extern WINDOW *main_sub/*, *win_for_menu*/;
+#define KNOWN_APS _("Known Access Points")
+
+extern WINDOW *main_win, *main_sub /* *win_for_menu */;
 extern short ap_type;
 extern int sockfd, atmel410_filter;
 extern struct in_addr ap_ip;
@@ -151,19 +152,8 @@ void APs()
        wattrset(main_sub, A_NORMAL);
        mvwaddstr(main_sub, 12, 20, _("Do you want to continue? "));
        wrefresh(main_sub);
-       print_help(_("(Y - Yes; N - No (it's safer to answer No)"));
-       i = 1;
-       while (i)
-           switch (getch()) {
-           case 'Y':
-           case 'y':
-               clear_main(3);
-               i = 0;
-               break;
-           case 'n':
-           case 'N':
-               goto quit;
-           }
+       if (help_ysn())
+           goto quit;
 
        needs_opmode_restore = 1;
        print_help(WAIT_RET);
@@ -185,6 +175,9 @@ void APs()
        sleep(7);
     }
 
+    sprintf(message, "%s%c", VIEW, ap_viewtype + '0');
+    print_top(message, KNOWN_APS);
+
 get_stats:
     varbinds[0].oid = KnownAP;
     varbinds[0].len_oid = sizeof(KnownAP);
@@ -199,9 +192,6 @@ get_stats:
 
 
 show_stats:
-    print_title(_("Known Access Points"));
-    print_viewtype(ap_viewtype);
-
     /* display column info in main_sub */
     mvwin(main_sub, 0, 0);
     wattrset(main_sub, COLOR_PAIR(3));
@@ -316,17 +306,18 @@ show_stats:
        /* display RSSI and LQ indicators */
        switch (ap_viewtype) {
            case 1:
-               sprintf(message, "%3d", -96 + app->q1);
-               mvwaddstr(main_sub, aps_num+1, 56, message);
+               sprintf(message, "%3d%%",
+                   (int)((minimum (app->q1, 40)) * (float)2.5));
+               mvwaddstr(main_sub, aps_num+1, 55, message);
                if (ap_type == ATMEL410) {
-                   sprintf(message, "%3d", (int)(100 - (minimum (app->q2, 40)) * (float)2.5) );
-                   mvwaddstr(main_sub, aps_num+1, 61, message);
+                   sprintf(message, "%3d%%",
+                       (int)(100 - (minimum (app->q2, 40)) * (float)2.5) );
+                   mvwaddstr(main_sub, aps_num+1, 60, message);
                }
                break;
            case 2:
-               sprintf(message, "%3d%%",
-                   (int)((minimum (app->q1, 40)) * (float)2.5));
-               mvwaddstr(main_sub, aps_num+1, 55, message);
+               sprintf(message, "%3d", -96 + app->q1);
+               mvwaddstr(main_sub, aps_num+1, 56, message);
                if (ap_type == ATMEL410) {
                    sprintf(message, "%3d%%",
                        (int)(100 - (minimum (app->q2, 40)) * (float)2.5) );
@@ -347,37 +338,37 @@ show_stats:
 
     /* display legend in main_sub */
     switch (ap_viewtype) {
-       case 2:
-           mvwaddstr(main_sub, LINES - 7, 0,
-               _("CN: Channel Name; P: Preambule Type (S: Short; L: Long);"));
+       case 1:
            mvwaddstr(main_sub, LINES - 6, 0,
-               _("RSSI: Radio Signal Strength Indicator [%];"));
+               _("CN: Channel Name; P: Preambule Type (S: Short; L: Long);"));
+           mvwaddstr(main_sub, LINES - 5, 0,
+               _("RSSI: Radio Signal Strength Indicator [%]"));
            if (ap_type == ATMEL410)
-               mvwaddstr(main_sub, LINES - 5, 0, _("LQ: Link Quality [%]"));
+               waddstr(main_sub, _("; LQ: Link Quality [%]"));
            break;
-       case 1:
-           mvwaddstr(main_sub, LINES - 7, 0,
-               _("CN: Channel Name; P: Preambule Type (S: Short; L: Long);"));
+       case 2:
            mvwaddstr(main_sub, LINES - 6, 0,
-               _("RSSI: Radio Signal Strength Indicator [dBm];"));
+               _("CN: Channel Name; P: Preambule Type (S: Short; L: Long);"));
+           mvwaddstr(main_sub, LINES - 5, 0,
+               _("RSSI: Radio Signal Strength Indicator [dBm]"));
            if (ap_type == ATMEL410)
-               mvwaddstr(main_sub, LINES - 5, 0, _("LQ: Link Quality [%]"));
+               waddstr(main_sub, _("; LQ: Link Quality [%]"));
            break;
        case 3:
-           mvwaddstr(main_sub, LINES - 7, 0,
-               _("CN: Channel Name; P: Preambule Type (S: Short; L: Long);"));
            mvwaddstr(main_sub, LINES - 6, 0,
-               _("RSSI: Radio Signal Strength Indicator [raw];"));
+               _("CN: Channel Name; P: Preambule Type (S: Short; L: Long);"));
+           mvwaddstr(main_sub, LINES - 5, 0,
+               _("RSSI: Radio Signal Strength Indicator [raw]"));
            if (ap_type == ATMEL410)
-               mvwaddstr(main_sub, LINES - 5, 0, _("LQ: Link Quality [raw]"));
+               waddstr(main_sub, _("; LQ: Link Q. [raw]"));
            break;
     }
     wrefresh(main_sub);
 
     if (ap_type == ATMEL410)
-       print_help(_("# con. to this AP; R refresh with reset; S refresh w/o reset; T toggle; Q quit"));
+       print_help(_("# con. to AP #; R refresh with reset; T toggle; Q quit; Other = refr. w/o reset"));
     else /* ATMEL12350 */
-       print_help(_("# con. to this AP; R initiate AP scan; S refresh view; T toggle view; Q quit"));
+       print_help(_("# con. to AP #; R initiate AP scan; T toggle view; Q quit; Other = refresh view"));
 
        while (1)
            switch (i = getch()) {
@@ -561,18 +552,19 @@ show_stats:
                        getch();
                    }
                    goto get_stats;
-           case 'S':
-           case 's':
-                   print_help(WAIT_RET);
-                   clear_main(0);
-                   goto get_stats;
            case 'T':
            case 't':
                    ap_viewtype += 1;
                    if (ap_viewtype > 4)
                        ap_viewtype = 1;
                    clear_main(0);
+                   sprintf(message, "%s%c", VIEW, ap_viewtype + '0');
+                   print_top(message, KNOWN_APS);
                    goto show_stats;
+           default:
+                   print_help(WAIT_RET);
+                   clear_main(0);
+                   goto get_stats;
             }
 
   restore_before_exit:
@@ -598,7 +590,7 @@ show_stats:
  exit:
     getch();
  quit:
-    print_title("");
+    print_top(NULL, NULL);
     clear_main(0);
 }