AmendHub

Download:

jcs

/

wifi_da

/

amendments

/

2

window: Clamp found networks to tmpnets size


jcs made amendment 2 about 1 year ago
--- window.c Tue Aug 22 23:18:00 2023 +++ window.c Fri Sep 8 16:37:24 2023 @@ -48,14 +48,14 @@ create_window(short ctlrefnum) #if 0 /* system 6 does not seem to support popupMenuProc */ ssid_list = NewControl(win, &ssid_menu_rect, 0, true, 0, - OwnedResourceID(SSID_MENU_ID), 0, popupMenuProc /* + popupFixedWidth*/, 0L); + OwnedResourceID(SSID_MENU_ID), 0, popupMenuProc + popupFixedWidth, 0L); #endif update_window(true); if (wifi_scsi_id == WIFI_SCSI_ID_FINDING) wifi_scsi_id = scsi_find_wifi(); - + if (wifi_scsi_id == WIFI_SCSI_ID_NONE) { da_state = STATE_IDLE; SetItem(ssid_menu, 1, NO_DEVICE_TEXT); @@ -163,6 +163,7 @@ update_wifi_ssid_list(void) count = scsi_wifi_scan_results(wifi_scsi_id, wifi_scan_networks, nitems(wifi_scan_networks)); + if (count == 0) { memcpy(&wifi_scan_networks, &wifi_cur_info, sizeof(wifi_cur_info)); @@ -170,6 +171,9 @@ update_wifi_ssid_list(void) } else { memcpy(&tmpnets[0], &wifi_cur_info, sizeof(wifi_cur_info)); + if (count > nitems(tmpnets)) + count = nitems(tmpnets); + for (n = 0, m = 1; n < count; n++) { if (strcmp(wifi_scan_networks[n].ssid, wifi_cur_info.ssid) == 0) @@ -182,7 +186,7 @@ update_wifi_ssid_list(void) memcpy(&wifi_scan_networks, &tmpnets, sizeof(wifi_scan_networks)); } - + if (wifi_scan_networks[0].ssid[0] == '\0') strlcpy(wifi_scan_networks[0].ssid, NO_NETWORK_TEXT, sizeof(wifi_scan_networks[0].ssid)); @@ -190,7 +194,7 @@ update_wifi_ssid_list(void) /* leave the first item and we'll set its text later */ while (CountMItems(ssid_menu) > 1) DelMenuItem(ssid_menu, 2); - + for (n = 0, mitem = 1; n < count; n++) { /* * InsMenuItem supports meta chars in item text which can @@ -209,7 +213,7 @@ update_wifi_ssid_list(void) strcmp(wifi_scan_networks[n].ssid, wifi_cur_info.ssid) == 0); mitem++; } - + update_window(true); } @@ -219,6 +223,7 @@ activate_window(bool activate) Rect r; GrafPtr savePort; +#if 0 GetPort(&savePort); SetPort(win); r = win->portRect; @@ -226,6 +231,7 @@ activate_window(bool activate) r.left = r.left - 16; InvalRect(&r); SetPort(savePort); +#endif } void